Jump to content

External Link and the Onclick() Function


iwato

Recommended Posts

BACKGROUND:  I have a page with a link whose normal behavior is suppressed in order to make room for a script that produces a gallery of frames when the new page opens. 

The LINK

<div class="moji">
    <a id='hito_rireki' 
       onclick="return false;" 
       href="Emblem/hito.html">
      <img src="Emblem/_Images/to.gif" width="105" height="90"   alt="(人という文字) The Sino-Japanese Character for Person" title="クリックして下さい!" />
  	</a>
</div>

QUESTION:  Is there a way to trigger this same link from a completely different page that does not involve the use of a GET or POST HTTPRequest?

Roddy

 

Link to comment
Share on other sites

Yes! there is

        <div id="dumpExternalLink"></div>
        <script>
          $(function() {
            //load element from other page with specific id or class to a specific id location, 
            //use callback to wait until fully loaded before removing onclick attribute and triggering a click event
                $('#dumpExternalLink').load('newhtml5-03.html #testext2', function() {
                  $(this).find('#testext2').removeAttr('onclick');
        $(this).find('#testext2')[0].click();
                });

            });

 

Link to comment
Share on other sites

Dsonesuk:  I am not sure that I understand what you are recommending.  Is it

  1. Create a div and a function on the current page  that is triggered when this div is clicked.
  2. Load with this click only that portion of the page to which the current page links and contains the link whose normal functioning I wish to suppress and replace with some other function.
  3. Activate this some-other-function.

If it is not, please elaborate further.  If it is, please confirm.

Roddy

Edited by iwato
Link to comment
Share on other sites

The code is placed on the other page, this code will go to the page with suppressed default action link, use the links id to select that specific link html, insert it into a div with specific id, remove OR not remove the JavaScript onclick attribute with "return false", then force a click event on that link.

You just mentioned the link, but you can copy any specific html preferable with an id identifier, but you could use class name, but you would have to use a index identifier if there are more than one.

The code above works after page load, but you can attach it to another event also.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...