|
|
|
making javascript libs?
|
Original Message
|
Name: liliyaw
Date: January 5, 2006 at 08:37:38 Pacific
Subject: making javascript libs?OS: xpCPU/Ram: 250 |
Comment: I have a .jsp file that's getting larger by day. This .jsp file is used in ONLY one html page. I will be making more html files that will use somewhat but not completely similar .jsp scripts. So I'd like to find a way to abstract that file somehow and use it across other pages with some extra .jsp files that would be more particular to html pages. How can I import and use .jsp files inside of jsp files? Can this be done? I'd appreciate any input. Thanks.
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: SN
Date: January 5, 2006 at 09:52:16 Pacific
|
Reply: (edit)How does this have anything to do with javascript? .jsp files are typically "java server pages", which are a completely different and unrelated animal. If you really do mean javascript and you're using .js files, you can include them by using the [script src='path_to_file.js'] in the html. Good luck, -SN
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Michael J (by mjdamato)
Date: January 5, 2006 at 09:54:27 Pacific
|
Reply: (edit)Personally I woud just include a 2nd [script language="JavaScript" src="name.jsp"][script] on those pages that needed the 2nd file. However, calling a 2nd external file from one file sounds like it should be possible, but couldn't find anything with a cursory search. Michael J
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: SN
Date: January 5, 2006 at 10:18:18 Pacific
|
Reply: (edit)Ah...If that's what you're trying to do, I bet you could do it with something like: document.write("<script src='pathto2ndfile.js' />"); -SN
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: liliyaw
Date: January 5, 2006 at 14:09:22 Pacific
|
Reply: (edit)I'm working with .js files not .jsp - I appologize. So I'd like to import a .js file into a .js file which in tern is used in a .html file. And you're suggesting inserting the line: document.write("<script src='script#2.js' />"); into a script#1.js And I could use script#1.js in a .html only. Is this it?
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: SN
Date: January 5, 2006 at 14:46:47 Pacific
|
Reply: (edit)Hmmm...I just tried it, and it worked in firefox but not IE. Interestingly, I could see the second script in IE's DOM, but nothing after it, as if that document.write completely stops the page from rendering in IE. I'll keep looking. Good luck! -SN
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: liliyaw
Date: January 5, 2006 at 14:55:39 Pacific
|
Reply: (edit)I'm looking at DOM as well. There are several issues with what I have now. Here is what I have: var js = document.createElement('script'); js.setAttribute('src', 'dirsc0.js'); document.body.appendChild(js); // the body is not defined and also // how to get to setText() in dirsc0.js?
Report Offensive Follow Up For Removal
|
|
Response Number 9
|
Name: Michael J (by mjdamato)
Date: January 6, 2006 at 11:20:33 Pacific
|
Reply: (edit)Something else that may be of use that I did not see mentioned on that page is that you can dynamically change the src for a javascript include (as opposed to writing ina new one) by using the following: [script language="javascript" src="file1.js" id="jsInclude"][/script] Then later you can change the source that was loaded with: document.getElementById('jsInclude').src = "file2.js"; I used this on a photo gallery page to dynamically load a different photo album without having to reload the page. Michael J
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|