Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript document.domain

Tags:

javascript

I'm trying to access a work server for use with an application called Spotfire. My colleague who passed me this is now off for a couple of weeks, and I have an issue with what he advised me.

Effectively when I run my web app via localhost, I get an error saying that I cannot access my work server. My colleague had said that I need to set document.domain to our work domain, but when I do this as such:

document.domain = "workdomain.net";

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

Thanks,

Darren.

like image 941
Darren Young Avatar asked Aug 01 '11 12:08

Darren Young


1 Answers

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 it does so, the shorter domain is used for subsequent origin checks."

The reason you're getting the javascript error is because you're trying to set the document.domain to a completely different domain than your current one ("localhost").

Rather than this, I suggest you add an entry to your host file...

127.0.0.1 local.workdomain.net

...and then navigate to local.workdomain.net

like image 174
Ash Eldritch Avatar answered Nov 11 '22 15:11

Ash Eldritch