Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 25th, 2007, 05:13 AM
Registered User
 
Join Date: Oct 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javascript varaible



<script>var filePath= "/TSI/jsp/openhyperlink.jsp?fileName=/u03/WebSphere/AppServer/tsi/app/pdi/";</script>


<script src= filePath+"js/dtree/dtree.js" type="text/javascript"></script>

Is this right? How to append javascript varaibles in script's src? How to use java script variables in href tag?pls help

I tried this also,but not working

<SCRIPT LANGUAGE="JavaScript" ><!--document.write('<src="'+filePath+'js/dtree/dtree.js" type="text/javascript">');
--></SCRIPT>

Thanks in advance

Regards,
jabeen



 
Old October 25th, 2007, 06:57 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You can do the second thing you tried but I think it's easier to set the src dynamically:
Code:
<script type="text/javascript" src="" id=script1" defer></script>
<script type="text/javascript">
document.getElementById("script1").src = filePath+"js/dtree/dtree.js";
</script>
But if you have the variable available it must be known server-side so why not fill in then (asp.net example)?
Code:
<script type="text/javascript" src="<% = pathToFile %>js/dtree/dtree.js"></script>
--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript. Magxtopher Javascript 2 April 1st, 2014 09:27 PM
stop current javascript function using javascript sakthi Javascript 3 June 2nd, 2008 03:30 PM
how can i do this in javascript ? jjk2 Java Basics 0 May 17th, 2008 08:11 PM
How to assign xsl param with java script varaible Sanjay.Verma XSLT 1 November 21st, 2006 04:34 AM
"text/javascript" and "javascript" rupen Javascript 1 June 24th, 2005 07:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.