Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Advanced Hyperlinking Question


  • Please log in to reply

#1
deadturkey12

deadturkey12

    New Member

  • Member
  • Pip
  • 4 posts
What is the html you would need in order for a hyperlink you click on to redirect you to a page and then put the cursor in a certain spot on that page?

I know how to have the hyperlink direct you to a link but specifically how to make it so it redirects you to the page and puts the cursor in that spot where you want it to be.

For example, something that says sign up now and then they are on the blog page and it redirects them to the subscribe to mailing list page and puts the cursor in the first name part for signing up for your mailing list.

Thank you,
Caleb
  • 0

Advertisements


#2
AstraNut

AstraNut

    Member

  • Member
  • PipPipPip
  • 465 posts
Could try:

<head>
<script type="text/javascript">
function setFocus()
{
document.getElementById("fname").focus();
}
</script>
</head>

<body onload="setFocus()">
<form action="none">
Name: <input type="text" id="fname" size="30"><br />
Age: <input type="text" id="age" size="30"> 
</form>
</body>

Or...

<form name="myform" action="none">
<input type="text" name="mytextfield">
</form>

<body OnLoad="document.myform.mytextfield.focus();">

Be sure to add the other proper HTML tags and the document type you use.

Edited by AstraNut, 12 May 2011 - 11:19 PM.

  • 0

#3
deadturkey12

deadturkey12

    New Member

  • Topic Starter
  • Member
  • Pip
  • 4 posts
Thanks a lot! :) Would these codes work if you were at the bottom of a page and you had a hyperlink and you wanted it to take you up to the top of the page and insert the cursor in a certain spot at the top of the page?

Thanks,
Caleb
  • 0

#4
AstraNut

AstraNut

    Member

  • Member
  • PipPipPip
  • 465 posts
Haven't tried it for those links that take you to a section of your page. Those are called named anchors:

Named Anchors:

Those are called named anchors. Scroll down to the title "The name Attribute" for good examples: http://www.w3schools.../html_links.asp

You can edit and try your own code out online here: http://www.w3schools..._link_locations

Examples:

Linking from a section on one web page to a section on another web page:

Using an image as the link:

<div><a href="http:// your_site.com/ html_links.htm#animals"><img style="width: XXpx; height: YYpx; border: 0;" src="Path to image" alt="Text Description"></a></div>

(Spaces added to show all the code for "href")

Text Link:

<div><a href="http://your_site.com...#animals">Visit My Animals Photos</a></div>

Target Text Link on External Page:

<div><a name="animals">My Animals Photos</a></div>

Possibly would work if you had to bring focus to a form's input field or a textarea box.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP