|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm looking for a way of placing repetitive javascript code in a seperate file and linking to it. I have tried this via the <script src="name.js"></script> but I have been getting errors. Here is the redundant code I would like to eliminate:
<IFRAME SRC="http://imgserv.adbutler.com/adserve/;ID=102291;size=88x31;setID=17688; aff=on;loc=0;type=iframe" WIDTH=88 HEIGHT=31 FRAMEBORDER=0 BORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 VSPACE=0 HSPACE=0 SCROLLING=NO> <SCRIPT SRC="http://imgserv.adbutler.com/adserve/;ID=102291;size=88x31;setID=17688; aff=on;loc=0;type=js" LANGUAGE="JAVASCRIPT"> </SCRIPT> <NOSCRIPT> <a href="http://imgserv.adbutler.com/go2/;ID=102291;size=88x31;setID=17688;aff =on;loc=0"> <img src="http://imgserv.adbutler.com/adserve/;ID=102291;size=88x31;setID=17688; aff=on;loc=0;type=img" border="0" height="31" width="88"></a> </NOSCRIPT> </IFRAME> help would be appreciated |
|
#2
|
|||
|
|||
|
Is your name.js file written in javascript (with document.write to display all the lines)? I'm pretty sure that it needs to be.
|
|
#3
|
|||
|
|||
|
I am not sure what you mean by document.write, so I probably left something out. So, javascript needs beginning and ending tags like html files do? I can't just cut and paste the code and save it as a .js?
The code that I put up is the banner rotation code on my site. All I did was cut and paste it and try and save it as a .js. I don't know anything about javascript other than how to cut and paste it into a .html file. <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by RyanP: Is your name.js file written in javascript (with document.write to display all the lines)? I'm pretty sure that it needs to be.[/quote] [This message has been edited by kprag (edited September 04, 2000).] |
|
#4
|
|||
|
|||
|
I see, I assumed that you knew Javascript. The included file in a <script src=" ... "> tag must be composed of Javascript itself. Using document.write to display the HTML for your banner rotation would be quite simple.
document.write("line 1"); document.write("line 2"); etc. But keep in mind that any user without a Javascript compatible browser or a user who has turned off Javascript would not see anything from this included file. I believe that the ideal solution would be to use SSI (server-side includes) for this case. |
|
#5
|
|||
|
|||
|
I did some monkeying around and I'm guessing that this might work
<SCRIPT LANGUAGE="JavaScript"> document.write("<A HREF="pagethat willlinkto.jhtml?"); var ID = "102291"; var size = "88x31"; var setID = "17688"; var aff = "on"; var loc = "0"; var type = "js"; document.write("ID=" + ID + "&size=" + size + "&setID=" + setID + "&aff=" + aff + "&loc=" + loc + "&type=" + type + ((context.length==0)?"":"&context="+context)); document.write("" TARGET="_parent">"); </SCRIPT> I DON'T KNOW IF IT IS RIGHT, BUT HERE IS THE INFO THAT I COPIED FROM. <!-- Begin AdRotator.com's AdButler Code --> <IFRAME SRC="http://imgserv.adbutler.com/adserve/;ID=102291;size=88x31;setID=17688;aff=on;loc=0;type=iframe" WIDTH=88 HEIGHT=31 FRAMEBORDER=0 BORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 VSPACE=0 HSPACE=0 SCROLLING=NO> <SCRIPT SRC="http://imgserv.adbutler.com/adserve/;ID=102291;size=88x31;setID=17688;aff=on;loc=0;type=js" LANGUAGE="JAVASCRIPT"> </SCRIPT> <NOSCRIPT> <a href="http://imgserv.adbutler.com/go2/;ID=102291;size=88x31;setID=17688;aff=on;loc=0"> <img src="http://imgserv.adbutler.com/adserve/;ID=102291;size=88x31;setID=17688;aff=on;loc=0;type=img" border="0" height="31" width="88"></a> </NOSCRIPT> </IFRAME> <!-- End AdRotator.com's AdButler Code --> |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > linking to repetitive code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|