We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

BASE HREF, Browser URL, and JS Problems!

ljaques
ljaques asked
on
Medium Priority
482 Views
Last Modified: 2008-03-17
I registered a domain name with Internic and it reads: mydomain.com.  I hooked up with an IPP to provide hosting services for my website.

My webpages make use of Javascript, specifically, it uses: DOCUMENT[grfx].src  to change one graphic to another.  It contains a relative URL call to fetch the graphic images. ie. DOCUMENT[grfx].src="p/pic10.jpg".  In the HTML code I placed the following in the <HEAD area: <BASE HREF="mydomain.com">.

Now when I access my webpage with the URL "mydomain.com" (from within a browser) it naturally calls up my site and I can naviagte thru it as expected.  But when I use the URL "www.mydomain.com" it does call up my site but when I navigate thru it I get the error message:
---
Javascript error: http://www.mydomain.com/top.shtml at line 33

Access disallowed from scripts at http://www.mydomain.com/top.shtml to documents at another domain.
---

What is going on here?  I thought both URLs are the same, that is, they point to the same IP #.  Does JS have a serious flaw or what?  Is there a solution to such a problem?

I want to have users of my site to access it with either WWW.MYDOMAIN.COM or simply MYDOMAIN.COM.

Thanks.
Comment
Watch Question

Commented:
Is your site really mydomain.com, or can you give an actual pointer to it so we can look at the code?
IT Expert
CERTIFIED EXPERT
Top Expert 2009
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Mplungjan, I set the document.domain as you said but it brought up the error message: Illegal document.domain value mydomain.com

Any solutions?


Michel PlungjanIT Expert
CERTIFIED EXPERT
Top Expert 2009

Commented:
The page MUST then be loaded from a site who's domain ends in mydomain.com.
The browser will only allow you to set the domain to the actual domain. Did you perhaps try it from your harddisk?

Michel
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.