Solved

Javascript window.location.hash IE problems

Posted on 2008-06-25
3
7,499 Views
Last Modified: 2013-12-08
Alright this peice of code

<script type="text/javascript">
      window.location.hash = '#' + document.cookie;
      alert(document.cookie);
</script>

Works perfect with FF but when I run it in IE it almost shows me the alert window.location.hash does not work with my IE7 any reasons why? Any workarounds? And yes alert gives me the value its suppose to so I know the cookie peice is working.

Thanks
0
Comment
Question by:aumudin
  • 2
3 Comments
 
LVL 4

Author Comment

by:aumudin
ID: 21868067
made some progress...

im using jquery / thickbox iframe modal. So the problem is when in IE window.location.hash tries to use it on the parent window.

Im now trying to figure out how to make it do it on the modal window
0
 
LVL 16

Expert Comment

by:Lolly-Ink
ID: 21880192
This example works for me:

<html>
<script type="text/javascript">
   document.cookie = "divBottom";
 
   function test()
   {
      window.location.hash = '#' + document.cookie;
   }
</script>
<body onload="test()">
   <div id="divTop" style="height:1000">Top</div>
   <div id="divBottom">Bottom</div>
</body>
</html>

Open in new window

0
 
LVL 4

Accepted Solution

by:
aumudin earned 0 total points
ID: 21880543
Yup your very correct that works perfectly just not in a modal window. Reason I have come to find out is IE renders to slowly but reads the code fast so the function even on the onload event executes befor it can find the anchors.

We ended up having to make JavaScript wait a few milliseconds and then it worked perfect.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

856 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