# My fix for loadVars with and without "www."

**URL:** <https://forum.kirupa.com/t/my-fix-for-loadvars-with-and-without-www/177433>\
**Category:** flash\
**Created:** [February 1, 2006, 10:07pm UTC](https://forum.kirupa.com/t/my-fix-for-loadvars-with-and-without-www/177433 "2006-02-01T22:07:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mickshake](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mickshake/32/1353_2.png) [@mickshake](https://forum.kirupa.com/u/mickshake)\
**Post date:** [February 1, 2006, 10:07pm UTC](https://forum.kirupa.com/t/my-fix-for-loadvars-with-and-without-www/177433/1 "2006-02-01T22:07:29Z")

</div>

Working with loadvars can be frustrating if your calling vars from “[www.website.com/getVars.php](http://www.website.com/getVars.php)” and testing them by navigating to “[website.com/getVars.php](http://website.com/getVars.php)”. Flash will not load vars accross a domain (cause your missing the www) without adding a policy file. There are a couple ways around this:

1. Don’t use absolute paths when working with loadvars.

The issue here is testing locally and on the web, you can’t load vars from getVars.php locally if you’re web server is generating the file with a database…

1. Force your users to include www. before the domain name.

I work for a tv network and I’m finishing up 4 flash sites that all use loadvars and I felt like writing a script that would work for all of them, instead of one for each site. The following is the result, and I thought I would share it with the faithful kirupa nerds.

\<script language=“javascript”\>  
var thisURL = “” + window.location;  
var WWW = (thisURL.indexOf(“www”));  
var dissect = thisURL.split("/");  
if((thisURL.indexOf(“www.”)\<=0) && dissect[2].indexOf(“www”)\<=0) {  
dissect.splice(2,1,“www.” + dissect[2]);  
window.location= dissect.join("/");  
}  
\</script\>

> **[Christian TV Network | Watch TV Programmes, Movies & Specials - Slides |...](https://ini.tv/inspiration-tv-your-place-for-spiritual-enrichment/)**
>
> Inspiration TV - an Outreach of Inspiration Ministries. Enjoy a Christian TV Network & watch Christian programmes like Joel Osteen, Charles Stanley & more.

  

> **[Christian TV Network | Watch TV Programmes, Movies & Specials - Slides |...](https://ini.tv/inspiration-tv-your-place-for-spiritual-enrichment/)**
>
> Inspiration TV - an Outreach of Inspiration Ministries. Enjoy a Christian TV Network & watch Christian programmes like Joel Osteen, Charles Stanley & more.

  

> **[Christian TV Network | Watch TV Programmes, Movies & Specials - Adapted...](https://ini.tv)**
>
> Inspiration TV - an Outreach of Inspiration Ministries. Enjoy a Christian TV Network & watch Christian programmes like Joel Osteen, Charles Stanley & more.

  

> **[Christian TV Network | Watch TV Programmes, Movies & Specials - Slides |...](https://ini.tv/inspiration-tv-your-place-for-spiritual-enrichment/)**
>
> Inspiration TV - an Outreach of Inspiration Ministries. Enjoy a Christian TV Network & watch Christian programmes like Joel Osteen, Charles Stanley & more.

I compressed (and actually made the code more scalable) from 23 lines to 6  
Enjoy! let me know of any errors 😏
