Skip to content

Instantly share code, notes, and snippets.

@uhunkler
Last active December 16, 2015 17:50
Show Gist options
  • Save uhunkler/5473434 to your computer and use it in GitHub Desktop.
Save uhunkler/5473434 to your computer and use it in GitHub Desktop.
doJavaScript - JSTalk browser
/**
* Execute JavaScript in the browser
*
* @param {string} js JavaScript string
* @required {object} browsername the browser name
* @required {object} browser the reference to the browser
* @required {object} tab the reference to the active tab
* @return {mixed} return value from JavaScript
*/
function doJavaScript( js )
{
result = '';
if( browsername === "Safari" || browsername === "WebKit" )
{
result = browser.doJavaScript_in( js, tab );
}
else if( browsername === "Google Chrome" )
{
result = tab.executeJavascript( js );
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment