# JS links and anchors

**URL:** <https://forum.kirupa.com/t/js-links-and-anchors/177346>\
**Category:** web dev\
**Created:** [February 1, 2006, 5:00am UTC](https://forum.kirupa.com/t/js-links-and-anchors/177346 "2006-02-01T05:00:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PCGamre](https://avatars.discourse-cdn.com/v4/letter/p/ea666f/32.png) [@PCGamre](https://forum.kirupa.com/u/PCGamre)\
**Post date:** [February 1, 2006, 5:00am UTC](https://forum.kirupa.com/t/js-links-and-anchors/177346/1 "2006-02-01T05:00:44Z")

</div>

Here is what I want to do:

have a link with an anchor, if anchor name is “a1” then javascript function pops up window and goes to an anchor in the popped up window doc (say, \<a name=“h1”\>Topic\</a\>

If i go to next link and it has anchor named “a2”, then js function runs and pops up window and goes to anchor “h2” in popped up window.

I already know how to pop up a window and all that, I’m just not sure how to access the anchor name from the js function, not sure of the terminology/syntax, etc.

I guess I would do something like:

```auto

		if (anchor = "help1"){
			url = "regis_help.htm";
			selectedPrint = window.open(url, 'selectedPrint', winprops);
			selectedPrint.focus();

  		}else if (anchor = "help2"){
			url = "regis_help.htm";
			selectedPrint = window.open(url, 'selectedPrint', winprops);
			selectedPrint.focus();

//etcetera..........

```

“winprops” is defined already in my pop up function… and of course the link that is pressed has :

\<a name=“help1” href=“javascript: showHelp();”\>Link\</a\>

So, basically all I need is help with the if-statement’s first line. I’m almost there, just need a little push. THanks.
