Fmdpa Posted April 21, 2010 Share Posted April 21, 2010 Here is the top section of one of my pages. Notice I have an embedded script and and external (linked) script. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title></title><link rel="Shortcut Icon" href="favicon.ico"><!--external stylesheet:--><link href="styles/style.css" rel='stylesheet' type="text/css"><script type="text/JavaScript">document.write("scripts/script1.js");function changeImage(id, src){ document.getElementById(id).src = src;}</script></head><body>... When I link that first script in there, it does everthing it is supposed to do, but it bumps the alignment of everything downward about 25-50px. I could embed that script as well, but it just would be very inconvenient in the event of an edit to the script. Any help? Link to comment Share on other sites More sharing options...
Synook Posted April 21, 2010 Share Posted April 21, 2010 You can't just write the path like that and hope it'll work - you have to either hard link it (using another script tag), or write out the entire script tag using JS. Your code will just print "scripts/script1.js" on the page. Link to comment Share on other sites More sharing options...
jeffman Posted April 21, 2010 Share Posted April 21, 2010 In other words, before or after your embedded script (not inside the script) place this pair of tags:<script type="text/javascript" src="scripts/script1.js"></script>and forget that document.write business. document.write solves a very narrow set of problems, and I see no evidence of any of them here. Link to comment Share on other sites More sharing options...
Fmdpa Posted April 21, 2010 Author Share Posted April 21, 2010 You can't just write the path like that and hope it'll work - you have to either hard link it (using another script tag), or write out the entire script tag using JS. Your code will just print "scripts/script1.js" on the page.Actually the script does everything it is supposed to do, but it messes up the alignment of the images. Link to comment Share on other sites More sharing options...
Fmdpa Posted April 21, 2010 Author Share Posted April 21, 2010 I tried adding two <script...></script> tags in the <head> but it only worked in Opera, not IE or FF. Link to comment Share on other sites More sharing options...
ShadowMage Posted April 21, 2010 Share Posted April 21, 2010 Actually the script does everything it is supposed to do, but it messes up the alignment of the images.That would be strange if it did. The way you have it with the document.write shouldn't work. I tested it just to verify, and it doesn't.Do like DD said and get rid of that document.write and place your script tags outside the embedded script. It should look like this:<script type="text/javascript" src="scripts/script1.js"></script><script type="text/javascript">...</script> Link to comment Share on other sites More sharing options...
Fmdpa Posted April 21, 2010 Author Share Posted April 21, 2010 That would be strange if it did. The way you have it with the document.write shouldn't work. I tested it just to verify, and it doesn't.Do like DD said and get rid of that document.write and place your script tags outside the embedded script. It should look like this:<script type="text/javascript" src="scripts/script1.js"></script><script type="text/javascript">...</script> That is actually what I did, but it didn't work in IE or FF. I'll try it again just to make sure. Link to comment Share on other sites More sharing options...
Fmdpa Posted April 22, 2010 Author Share Posted April 22, 2010 I saw that I was actually going like this: <script type="text/javascript" src="scripts/script1.js" /> Now it works. Link to comment Share on other sites More sharing options...
Fmdpa Posted April 22, 2010 Author Share Posted April 22, 2010 This was my real issue: <script type="text/javascript" src="scripts/script1.js" [b]\[/b]/><script type="text/javascript">...</script> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.