Javascript document.domain

I am trying to access a production server for use with the Spotfire application. My colleague, who passed this on to me, is now disconnected for a couple of weeks, and I have a problem with what he advised me.

Effectively, when I run my web application through localhost, I get an error that I cannot access the production server. My colleague said that I need to set document.domain in our workspace, but when I do it as such:

document.domain = "workdomain.net"; 

I get an error that this is an invalid argument. Any idea how to get around this?

Thanks,

Darren.

+4
source share
1 answer

From https://developer.mozilla.org/en/Same_origin_policy_for_JavaScript

"A script can set the value of document.domain to a subset of the current domain. If so, the shorter domain is used for subsequent origin."

The reason you get the javascript error is because you are trying to install document.domain in a completely different domain than your current ("localhost").

Instead, I suggest you add an entry to the host file ...

 127.0.0.1 local.workdomain.net 

... and then go to local.workdomain.net

+9
source

All Articles