Forum Moderators: open
addEvent(window, 'load', function() {
document.getElementById('query_string').focus()
});
...is part of a master JS file and specifically intended for content pages. I have music player pages which are also linked to the master JS file.
Both scripts need to somehow only be loaded on their intended pages. I have an idea of how to execute this but I need a little help refining it.
content.html will probally have something like...
<script type="text/javascript">
$pagetype = 'content';
</script>
Then for the script only intended for the content page would be something like...
if ($pagetype = 'content'){ *content script executes*}
else {return false;}
I figure it would be something like that (and vice versa for the other type of page. I haven't tried it yet but I am interested in input from the folks here. :)
<html>
<head>
<title>Test</title>
</head><body>
<script type="text/javascript">
if (document.getElementById("content")) {alert ("undefined");}
else {alert ("Defined");}
</script><div id="bob">
<p>Hello World</p>
</div></body>
</html>
<html>
<head>
<title>Test</title>
</head>
<body><div id="content">
<p>Hello World</p>
</div><script type="text/javascript">
if (! document.getElementById("content")) {alert ("undefined");}
else {alert ("Defined");}
</script></body>
</html>
Yeah...how will I be able to make this work in my master JS file? I've encountered this problem with script having to be in the page AFTER the code it was interacting with and I never figured that out. :(