Solved

BASE HREF, Browser URL, and JS Problems!

Posted on 1998-08-13
4
460 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.
0
Comment
Question by:ljaques
  • 2
4 Comments
 
LVL 2

Expert Comment

by:bernfarr
ID: 1268245
Is your site really mydomain.com, or can you give an actual pointer to it so we can look at the code?
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 100 total points
ID: 1268246
The browser is just doing as instructed - Netscape 3 introduced a stricter security so a script from one domain does not have access to another domain. This could have but isn't using the IP address.

To relax security, set the following in your scripts:
if (document.domain) document.domain='mydomain.com';

that will tell netscape that anything ending on mydomain.com is allowed to access the page.

Alternatively remove the BASE href

Michel

0
 

Author Comment

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

Any solutions?


0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1268248
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
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now