Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScript Bookmarklet; click button, reload page, then open page
    primarykey
    data
    text
    <p>I am trying to create a bookmarklet that follows this process:</p> <ol> <li>From any page, click the bookmarklet</li> <li>load a specific page.</li> <li>Trigger an input button which causes page to reload</li> <li>Once reloaded; open a new page; in this case a social media page.</li> </ol> <p>This is what I've written so far:</p> <pre><code>if (!($ = window.jQuery)) { // Inject jQuery to make life easier script = document.createElement( 'script' ); script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'; script.onload=SocialCredentials; document.body.appendChild(script); } else { SocialCredentials(); } function SocialCredentials(){ $('input:submit').trigger('click'); window.open('http://www.facebook.com', '_blank'); } </code></pre> <p>The button submit click causes the page to process and clear the credentials of the user so they can visit social sites. </p> <p>The above code works, but I want to make sure the page finishes loading before opening a new social media page. </p> <p>Do I need to add some kind of <code>wait()</code> function? If I do add a wait method, will it kill the JavaScript and not open the new window? I'm fairly new to JavaScript, so I'm not familiar with these types of mechanics. </p> <p>Edit:I should note that I don't have access or control to the page this bookmarklet will work on so I can't alter it's flow. What I'm trying to do is more of a favor for another department as a quick fix until they can make changes on their end. </p> <p>Edit2: Updated the process.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload