[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Struggling with a jump to bookmark command using javascript on page onload

Posted on 2006-04-06
8
Medium Priority
?
276 Views
Last Modified: 2008-02-01
Hi

I am sure this extremely simple, however I can't get it to work:

I have a variable that may or may not be populated.

If it is populated, I want an onload event in the <body> tag to jump down the page to a bookmark.

I have tried: <body onload="window.location.href=#bookmark"> but to no avail - I am sure I am missing something really simple!

Thanks for your help.
0
Comment
Question by:stuartbanks
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 16392430
Try:

    <body onload="window.location.hash=bookmark">
0
 

Author Comment

by:stuartbanks
ID: 16392490
hmmm, doesnt seem to work... any other ideas?
0
 
LVL 35

Accepted Solution

by:
TimYates earned 200 total points
ID: 16392575
Sorry...forgot the quotes...

   <body onload="window.location.hash='bookmark'">

Tim
0
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!

 

Author Comment

by:stuartbanks
ID: 16392978
great thanks for your help.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 16392999
:-)
0
 
LVL 9

Expert Comment

by:smaccari
ID: 16393681
Just to mention that your original code will do the job if you just add quotes to your #bookmark:

 <body onload="window.location.href='#bookmark'">

;)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…
Suggested Courses

872 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