473,735 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compaibility issue: window.location mismatch with browser locationbar

I already understand that one cannot disable a browser's
forward and back functions. This is a situation where I
have code working in Mozilla V1.6 and would like something
similar for Opera and IE.

I link within a page and display individual divisions of
that page, manipulating their visibility and display styles
with an onClick function. As long as I explicitly click a
link to progress, it works with browsers I've tried.

If I click the browser's back button I see the content of
the browser's location bar change as I expect. But I
need to set the visibility and display styles for the
corresponding division. In Netscape/Mozilla I have a little
function enabled by setInterval(). It looks to see if
window.location .hash matches the division which is visible
and modifies styles accordingly.

Under IE window.location .hash seems to be "stuck" at the
most "forward" link. Under Opera I can get only the URL
without the hash; it claims that the hash property is
undefined or empty. I've tried document.locati on and
document.URL with the same results.

Since there's no page load or unload involved, there's no
event generated; I could kludge some history of my own to
traverse.

Am I looking in the right place to get the hash info? Is
there some direct access to read the location bar?

Is there another approach to the problem, other than breaking
up the page so that I force a load or unload?

Thanks for any help.
Jul 23 '05 #1
5 7536
spam_me_ not wrote:
I already understand that one cannot disable a browser's
forward and back functions. This is a situation where I
have code working in Mozilla V1.6 and would like something
similar for Opera and IE.

I link within a page and display individual divisions of
that page, manipulating their visibility and display styles
with an onClick function. As long as I explicitly click a
link to progress, it works with browsers I've tried.

If I click the browser's back button I see the content of
the browser's location bar change as I expect. But I
need to set the visibility and display styles for the
corresponding division. In Netscape/Mozilla I have a little
function enabled by setInterval(). It looks to see if
window.location .hash matches the division which is visible
and modifies styles accordingly.

Under IE window.location .hash seems to be "stuck" at the
most "forward" link. Under Opera I can get only the URL
without the hash; it claims that the hash property is
undefined or empty. I've tried document.locati on and
document.URL with the same results.


Read the document.locati on.href and then parse it yourself. You should
know the current URL, simply remove that from the string and then read
the rest.

document.locati on.search might be an alternative, it would require you
use the ? instead of the #

Jul 23 '05 #2
>> ...
Under IE window.location .hash seems to be "stuck" at the
most "forward" link. Under Opera I can get only the URL
without the hash; it claims that the hash property is
undefined or empty. I've tried document.locati on and
document.URL with the same results.
Read the document.locati on.href and then parse it yourself. You

should > know the current URL, simply remove that from the string and
then read > the rest.
document.locati on.search might be an alternative, it would require

you > use the ? instead of the #

Thanks for the thoughts. But document.locati on.href shows the
same situation as document.locati on.hash and parsing it myself
would make no difference. (In fact, for debugging I displayed
..href so I could be sure of what was going on.)

I tried passing the information in document.locati on.search.
That causes other behaviors in IE and Opera but I still get
the same basic problems I had before.

I decided on a different approach. If the navigation history
within the page is actually useless since the navigation bar
is always available, then window.location .replace() will
avoid a history. The back button goes to my page's referrer,
and forward would go to some other page. That also allows me
to get rid of the setInterval() and the routine it invokes.

Again, it works in Mozilla/Netscape, but not in IE and Opera.
IE *keeps* the history, and the browser's back function leaves
the wrong section visible. Opera does the right thing with
the history but insists on forcing visibility and display
for the division I'm leaving. I have an alert() immediately
after the assignment into window.location so I can see the
*correct* division displayed while the alert() is active. I
then see it revert to the division I'm leaving once I dismiss
the alert().

Here's a code snippet that shows the basic setup:

var idList = new Array("sched", "lead", "cont");

function swapVisibility( theId) {
document.locati on.replace("vee blefetzer.html# " + theId);
var hideIt;
for (var i=0; i<idList.length ; i++) {
hideIt = document.getEle mentById(idList[i]);
hideIt.style.vi sibility = "hidden";
hideIt.style.di splay = "none";
}
var becomeVisible = document.getEle mentById(theId) ;
becomeVisible.s tyle.visibility = "visible";
becomeVisible.s tyle.display = "block";
alert(document. location.href+" \n"+theId);
return true;
} // end function swapVisibility

<a onclick="swapVi sibility('sched ');" href="#sched">. ..</a>
<a onclick="swapVi sibility('lead' );" href="#lead">.. .</a>
<a onclick="swapVi sibility('cont' );" href="#cont">.. .</a>

<div id="sched">
...
</div>
<div id="lead">
...
</div>
<div id="cont">
...
</div>

etc.

Am I using document.locati on.replace() correctly?
Jul 23 '05 #3
I think I can describe the solution to the problem as
breaking out of a Netscape V4 mindset. Instead of
changing visibility as part of an anchor tag, I use
the onClick within a paragraph tag. That immediately
gets rid of the navigation history in all browsers.
document.locati on.replace() is gone.

There's an option to view all sections at once. If
that's enabled, I shove the target location (hash)
into document.locati on. That gets back into the
navigation history again, but that's acceptable in
what is now a longish page.

The browser incompatibiliti es, well, chalk 'em up to
something else to remember for future work. This
approach is much cleaner, not just a "workaround ."
Jul 23 '05 #4
Richie wrote:
I think I can describe the solution to the problem as
breaking out of a Netscape V4 mindset. Instead of
changing visibility as part of an anchor tag, I use
the onClick within a paragraph tag. That immediately
gets rid of the navigation history in all browsers.
document.locati on.replace() is gone.


location is a property of the default window object, so it's
window.location .replace(). document.locati on is deprecated, has
been for a long time.

<url:
http://devedge.netscape.com/library/.../document.html
/>
"Do not use location as a property of the document object; use
the document.URL property instead. The document.locati on
property, which is a synonym for document.URL, is deprecated."

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #5
Grant Wagner wrote:
Richie wrote:

I think I can describe the solution to the problem as
breaking out of a Netscape V4 mindset. Instead of
changing visibility as part of an anchor tag, I use
the onClick within a paragraph tag. That immediately
gets rid of the navigation history in all browsers.
document.loca tion.replace() is gone.

location is a property of the default window object, so it's
window.location .replace(). document.locati on is deprecated, has
been for a long time.

<url:
http://devedge.netscape.com/library/.../document.html
/>
"Do not use location as a property of the document object; use
the document.URL property instead. The document.locati on
property, which is a synonym for document.URL, is deprecated."

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq


I tried all three variations along the way. Apologies for
using the deprecated property in my description.
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1834
by: mmac | last post by:
I am trying to create something like this: Response.Write "<a href=""javascript:openWindow('www.domain.com/events/EventDetails.asp?EventID=" & rsEvents("OccID") & "','Today','status=yes,scrollbars=yes,resizable=yes,width=500,height=500')"">" I know there is something wrong with the above, the example I drew from used "/dsn/wwwdomaincom" and I don't know what to do with "dsn" so I am trying to figure out how to make it work without it.
2
19193
by: jeff | last post by:
Hello, I'm building an internal web application using HTML/PHP/Javascript. The system is flexible to the point where the user can have as many browser windows open for each part of the system. I would like a browser window that has just gained the focus to refresh. Is this possible and how? Thanks,
2
2072
by: Ed Schimmel | last post by:
Hi All, I have a small question considiring the opening of a new window in javascript. As you all know the code below will open a new without any bars. But when I tried this code in IE6 it won't run. I have looked for some documentation but couldn't find all the 'new' parameters for IE6 to open a window without any bars. As far as I know the second argument in window.open is no longer there. Maybe some people can help me with my...
21
1993
by: Albretch | last post by:
Hi, client wants for a window with no toolbars to open (technical and 'esthetical' reasons) after the window, user clicks on, is being closed. I told them about security settings in browsers and no cross-browsers solutions and all of that we know, but they have told me they have seen that before and how then the annoying pop-up windows work? . . .
7
3227
by: E Michael Brandt | last post by:
I have been lurking here for some time, and now would like to ask a question of you clever coders: My JustSo PictureWindow 3 Extension for Dreamweaver has stumbled in the face of the new Opera 8. Jspw3 opens a popup window (using varname=window.open(...)) but there are now two problems: 1) Opera8 interprets a top,left of 0,0 to be top left of the browser window rather than of the entire screen, unlike the other modern browsers I've...
3
3805
by: Bob | last post by:
I am trying to create a popup page (to act as a menu) from a parent page. When the parent page (index.jsp) calls my popup function (see below) it will properly open the correct size browser window only if the browser that index.jsp is opened in is NOT maximized. If index.jsp is maximized and then I click on the test link that fires off the openMain function, the browser that is opened for the popup is also maximized. function...
2
12561
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser <form action="display.aspx" method="post" target="_blank"> will submit the form data and open display.asp in a new browser
4
3102
by: sid | last post by:
"about:blank" oepns new browser window I am writing a webpage that will run on other machines that I may or may not know about. My page is framed where frame1 controls the content of frame2. What I have found is that if the page in Frame2 fails to load and I get an error page. when I detect an error page I want to set frame2.location.href = "about:blank" and then write a temp error page until the server becomes available again. The...
1
2177
by: captainwin | last post by:
Here's the problem: - Website is ASP.NET 1.0 - Server is Windows Server 2003 - Browser is IE 6/7 - Client requests a mail merged MS Word 97 - 2003 document on the website, and the document gets created on the server. - Need to send the document to the client browser and delete the file from the server. Previously, the web application already did this, but after some hardware and location changes, the application no longer performs this...
0
8965
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8786
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9202
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8202
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6748
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2191
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.