Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to access hyperlinks automatically??

    Hi, does any1 out there know how write a Javascript that access a hyperlink, then access another hyperlink in the same website?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    with the click() function:

    document.getElementById("link_id").click();
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #3
    New Coder
    Join Date
    Jan 2003
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Hi brothercake, thanks a lot!
    But i've a problem here.. Besides "document.getElementById();", is there any other methods?? Bcos i'm currently writing a program which access a website and i'm not sure how to get the ElementById()...

    Btw, if a page, EG: www.testing.com/test.jsp?openview contains javascript:makechart().
    How can i access the above mentioned Javascript from a local page??

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well you have to assign the link an ID attribute, for example:

    <a href="something.html" id="mylink">

    then it would be

    document.getElementById("mylink");



    BTW - you shouldn't use the javascript: pseudo protocol in links; because it leaves nothing for non-JS browsers; it's better to go

    <a href="somepage.html" onclick="return myFunction()">

    then in myFunction you return false, to prevent the link being followed:
    Code:
    function myFunction()
    {
    
        // do whatever
    
        return false;
    
    }
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #5
    New Coder
    Join Date
    Jan 2003
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oic.. but if the <A HREF> doesn't contain ID, that means i can't get that method rite?? Coz i'm accessing someone else's page, and it has many hyperlinks, but it simply uses <A HREF="page1.jsp">...
    Ok, the scenario is i'm writing a JSP which will auto 'click' on the hyperlinks in the person's website. Coz each hyperlink contains some data file. The trouble is the person uses a Javascript function to open a new window for loading out a data file. And i'm suppose to call that javascript in that webpage, from my JSP... Do u think it's possible for me to do so???

  • #6
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can't access someone else's page, programmatically, if it's hosted at another domain.


  •  

    Posting Permissions

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