# JS to include JS scripts

**URL:** <https://forum.kirupa.com/t/js-to-include-js-scripts/235230>\
**Category:** Uncategorized\
**Created:** [August 9, 2007, 2:02pm UTC](https://forum.kirupa.com/t/js-to-include-js-scripts/235230 "2007-08-09T14:02:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dewey](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@dewey](https://forum.kirupa.com/u/dewey)\
**Post date:** [August 9, 2007, 2:02pm UTC](https://forum.kirupa.com/t/js-to-include-js-scripts/235230/1 "2007-08-09T14:02:12Z")

</div>

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…

```auto
<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
