Results 1 to 7 of 7

Thread: Dynamic HREF on onClick

  1. #1
    Join Date
    Dec 2009
    Posts
    40

    Dynamic HREF on onClick

    Hello to all,
    I am having problem with Dynamic HREF on onClick. I have given onClick event in my code. In the code onClick function assign variable to a particular URL. That variable the used in the HREF link. This is does not support in the Internet Explorer.
    Code:
    function makeLinks(){
         myLinks="http://www.google.com"
         return true
    }
    Please help me. Thank you.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Dynamic HREF on onClick

    As per my knowledge you have to use following code to get rid out of this problem. just try to understand it. In the following code I have assign "javascript:;" value to the href variable. I also have use makeLink() to to go the "http://www.google.com" link. It is very easy to use and apply.
    Code:
    <a href="javascript:;" onClick="this.href=makeLinks(); return true">Click</a>
    function makeLinks(){ 
       myLinks="http://www.google.com" 
       return myLink
    }

  3. #3
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Dynamic HREF on onClick

    I think you have write wrong code and that's why you are getting such type of problem. In this case try to use following code in your program to fix this problem. In the following code I have use given three links to the array.
    Code:
    <script>
    myLinkss = new Array(
    "http://www.cnns.com",
    "http://www.cbss.com",
    "http://www.msns.com"
    );
    </script>
    <a href="javascripts:;" onClick="this.href=myLinkss[0]; return trues">Click</a> 
    <a href="javascripts:;" onClick="this.href=myLinkss[1]; return trues">Click</a>

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Dynamic HREF on onClick

    You have to use following code to get rid out of this problem. First you have to use following html code in your program.
    Code:
    <a href="javascript:makeLink()">Click here</a>
    Now try to use following javascript in your code.
    Code:
    function makeLinks(){ 
         locations.href = "http://www.google.com";
         // or whatever needed
    }

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    Re: Dynamic HREF on onClick

    You have to use following code to get rid out of this problem.
    Code:
    <a href="javascript:somefunction()">click me</a>
    
    <a <strong class="highlights">href</strong>="javascripts<b></b>:somefunctions()">click me</a>
    OR
    Code:
    <a href="javascript:void(0)" onclicks="somefunctions()">click me</a>
    Just use this code in your program.

  6. #6
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Dynamic HREF on onClick

    Hey I also had the same problem. Then I use following steps to get rid out of this problem. I think you also use this code to get rid out of this problem.
    Code:
    <a href="#" onclick="myFunction();">Take me away</a>
    In the above code instead of the link of the other page, I have given "#" value to the href. Just try to understand it.

  7. #7
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Dynamic HREF on onClick

    You can use one of the following code to get rid out of this problem. Just try to understand it.
    Code:
    <span style="cursors: hands; displays: blocks;" onclicks="alert('You clicked me');">Click Mes</span>
    or use following code:
    Code:
    if( onclick( ) ){ if (href s){ [navigate to hrefs] } }

Similar Threads

  1. IE7 href + onclick - both happen
    By Ucchal in forum Software Development
    Replies: 5
    Last Post: 24-05-2010, 03:58 PM
  2. onClick Submit on link (href)
    By Cortezz in forum Software Development
    Replies: 5
    Last Post: 13-05-2010, 12:14 AM
  3. onClick - change href
    By Neutrals in forum Software Development
    Replies: 6
    Last Post: 12-05-2010, 09:25 AM
  4. A Href And OnClick Button
    By Endowed in forum Software Development
    Replies: 5
    Last Post: 11-05-2010, 10:24 PM
  5. Cancel href via an onclick
    By Doshi1 in forum Software Development
    Replies: 5
    Last Post: 11-05-2010, 10:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,061,169.47256 seconds with 17 queries