Jump to content

Set Focus on Element


chordsoflife

Recommended Posts

I need to set the focus on a particular element without added anything to the body or the head. Is there a way to do that? Here is the code I have to work with:

 

echo "<br /><center><a href='add_concert.php'>Add Another</a></center><br />\n";

 

I just want to be able to press enter on page load.

Link to comment
Share on other sites

you can add an onload() event to the actual body tag; that way it meets your requirements (not in the head or the body - but in the tag instead).

 

<body onload="document.getElementById('focal_link').focus()">

echo "<br /><center><a id='focal_link' href='add_concert.php'>Add Another</a></center><br />\n";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.