By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,936 Members | 1,396 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,936 IT Pros & Developers. It's quick & easy.

Creating and Using a String Object: Anchor() Method

P: 35
Hi Guys,

I've been cramming in and trying the anchor() method all day but I cannot seem to find the right syntax. What does the method do? How is it different to the Link() method

Expand|Select|Wrap|Line Numbers
  1. <script language = "javascript" type = "text/javascript">
  3. document.write("<p>");
  4. var txt="Hello world!";
  5. document.write(txt.anchor);
  6. document.all("myanchor") + "</p>");
  8. </script>
Jun 21 '07 #1
Share this Question
Share on Google+
1 Reply

rnd me
Expert 100+
P: 427
the anchor method creates an in-page link.

this is usefull for table of contents for long documents - clicking the chapter listing could scroll the page down right to the chapters test, like a pdf.

you pass it a name to use for the shortcut:

"chapter 1".anchor("ch1");

to just to that anchor, you use another anchor, whose href property is "#ch1".

this could be make via "Jump to Chapter One".link("#ch1")

i hope this sheds some light on these overlooked string methods.
Jun 21 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.