PDA

View Full Version : JS to include JS scripts...



dewey
August 9th, 2007, 10:02 AM
Hello everyone...

I know I am close here, but I can't seem to get the last step.

The pages I am working on have a reporting service. What I want to do is this: if the page is on the staging server, then I want it to report to the staging environment. If it is on prod, it can report to the production environment... I have this...


<script type="text/javascript">

if (location.href.indexOf("stage") == -1)
{
document.write("<script type=\"text/javascript\" src=\"scripts/s_code.js\"></script>");
}
else
{
document.write("<script type=\"text/javascript\" src=\"scripts/s_code_dev.js\"></script>");
}

</script>

tossing an alert at the top of that area, it doesn't fire...

Can anyone throw me a bone here? :thumb:

Thnx,

--d

simplistik
August 9th, 2007, 10:26 AM
http://www.vipdelivers.com/images/Pressed%20Bone.JPG


sorry.... had to... :smirk2:

kBisk
August 9th, 2007, 01:02 PM
try this, I couldn't figure out why it wouldn't work either, so I just starting pulling it apart:


<script type="text/javascript">
if (location.href.indexOf("stage") == -1){
document.write(unescape("%3C" + "script type=\"text/javascript\" src=\"scripts/s_code.js\"" + "%3E" + "%3C" + "/script" + "%3E"));
} else {
document.write(unescape("%3C" + "script type=\"text/javascript\" src=\"scripts/s_code_dev.js\"" + "%3E" + "%3C" + "/script" + "%3E"));
}
</script>