Results 1 to 3 of 3

Thread: JQuery > button > click created link

  1. #1

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000

    JQuery > button > click created link

    Hi again,

    I have this working in Chrome and Firefox (although Firefox blocked direct clicking on a created link - click a span in a link tho...)
    However, Edge/IE(?) runs the JS up to the JQuery trigger... and doesnt run the last bit.

    function dlResultos( mimeType ){
    	var al=$("#hiddenlink");
    	var dt = new Date();
    	var filename = ''+dt.getYear()+(dt.getMonth()+1)+dt.getDate()+dt.getHours()+dt.getMinutes()+dt.getSeconds()+"sql.txt";
        var elHtml = "";
    	var obj = document.getElementById("resultoHidden"); 
    	if( obj != null ) {	
    		elHtml = obj.innerHTML;
    		elHtml = elHtml.split("<br>").join("\r\n");
    		elHtml = elHtml.split("&nbsp;").join(" ");
    	if( elHtml.length>0 ) {
    			al = $("<a></a>");
    		al.attr('href','data:' + mimeType  +  ';charset=utf-8,' + encodeURIComponent(elHtml));
    		$("#hiddenlink span").trigger('click'); // < problem is here on edge
    		alert("Nada para salvar!");
    Does Edge have a security measure to block this type of clicking ?

    Note: running a Java JSP page... for the extra code not JS...

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  2. #2
    Lively Member
    Join Date
    Jan 2020

    Re: JQuery > button > click created link


    Please try this code,To JQuery > button > click created link

    <!DOCTYPE html>
    <html lang="en">
    <meta charset="utf-8">
    <title>jQuery Trigger Click on a Link</title>
    <script src=""></script>
    function doSomething(){
        alert("Click event is triggered on the link.");
        <p><a href="#skyImage" onclick="doSomething()">Bookmark link to an image</a></p>
        <button type="button">Trigger Click</button>
        <div style="margin-top: 800px;">
            <img src="/examples/images/sky.jpg" id="skyImage" alt="Cloudy Sky">
    I hope this code will be useful for you.
    Thank you

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: JQuery > button > click created link

    Quote Originally Posted by Prahlad View Post

    Please try this code
    If the OP is still waiting for a solution to this issue after nearly four years, I'd be gravely concerned. That's not to say that you should not provide advice, because it may help others who find this thread via a search. I'm not sure that the OP will be trying it though.

Posting Permissions

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

Click Here to Expand Forum to Full Width