Last active
December 16, 2015 17:50
-
-
Save uhunkler/5473434 to your computer and use it in GitHub Desktop.
doJavaScript - JSTalk browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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