HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 4th, 2000, 09:48 PM
kprag kprag is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 20 kprag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old September 4th, 2000, 10:21 PM
RyanP
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
  #3  
Old September 4th, 2000, 10:38 PM
kprag kprag is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 20 kprag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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).]

Reply With Quote
  #4  
Old September 5th, 2000, 12:14 AM
RyanP
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
  #5  
Old September 5th, 2000, 07:40 PM
kprag kprag is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 20 kprag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 -->

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > linking to repetitive code


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT