Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Javascript window.location.hash IE problems

Posted on 2008-06-25
3
Medium Priority
?
7,669 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
This article discusses how to create an extensible mechanism for linked drop downs.
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)
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.

916 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