Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 6 of 6

Thread: JS links and anchors

  1. #1

    JS links and anchors

    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:

    		if (anchor = "help1"){
    			url = "regis_help.htm";
    			selectedPrint = window.open(url, 'selectedPrint', winprops);
      		}else if (anchor = "help2"){
    			url = "regis_help.htm";
    			selectedPrint = window.open(url, 'selectedPrint', winprops);
    "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.

  2. #2
    eeeeh, don't worry about it, I worked out something easier.

  3. #3
    yeah..I was gonna say - Isn't there an easier way to do it?

    Care to enlighten me as to what you came up with?

  4. #4
    Hey, thanks for your interest. This is what I did:

    All my window properties were already defined, then I just wrote a short function for each. The "h" stands for which Help Section (marked with anchors) in the pop-up the user will be taken to

    function h1(){
    	url = "regis_help.htm#1";
    	selectedPrint = window.open(url, 'selectedPrint', winprops);
    function h2(){
    	url = "regis_help.htm#2";
    	selectedPrint = window.open(url, 'selectedPrint', winprops);
    function h3(){
    // etc
    // and so on...
    The purpose of this was, I was creating a form for users to fill out. Beside each form field was a little "Help" icon where they could click on and go to a specific section of text within a pop-up window. That's all. I was just trying to be efficient with my js, but then I just wanted to get it done...

    Take care.

  5. #5
    Registered User
    why not just have one function as so ...
    function showHelp(num){
        url = "regis_help.htm#"+num;
        selectedPrint = window.open(url, 'selectedPrint', winprops);
    and when you like to them do
    HTML Code:
    <a href="javascript:showHelp(1)" name="1">Link1</a>
    <a href="javascript:showHelp(2)" name="2">Link2</a>
    PHP Code:
    <zip> echo this; </zip

  6. #6
    Perfect. Well, if you would've answered earlier.... Hey, I'm still learning....

    Thanks antizip. That's exactly what I was looking for. That works perfectly, except I don't need the anchors there in the links that the users click; they go in the document in the window that pops up.

    Thanks again.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About kirupa.com Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012