Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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
  • 384 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
  • 384 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