Added a basic scriptapi with a test page.
Signed-off-by: retep998 <retep998@verizon.net>
This commit is contained in:
parent
3ecea83687
commit
7c059424de
15
scriptapi.js
15
scriptapi.js
@ -1,3 +1,14 @@
|
|||||||
function script_click_a(url) {
|
function script_fire_event(element, type) {
|
||||||
window.location.href = url;
|
//Todo - https://developer.mozilla.org/en-US/docs/DOM/document.createEvent
|
||||||
|
if (element.fireEvent) {
|
||||||
|
element.fireEvent('on' + type);
|
||||||
|
} else {
|
||||||
|
var obj = document.createEvent('Event');
|
||||||
|
obj.initEvent(type, true, true);
|
||||||
|
element.dispatchEvent(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function script_find_element(id) {
|
||||||
|
//Todo - Add parameters for rest of stuff
|
||||||
|
return document.getElementById(id);
|
||||||
}
|
}
|
14
testscript.html
Normal file
14
testscript.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Test</title>
|
||||||
|
<script type="text/javascript" src="scriptapi.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p><a id="foo" onclick="javascript:alert('Success!');">This will be clicked by the script</a></p>
|
||||||
|
<p><a id="bar" onclick="javascript:script_fire_event(script_find_element('foo'), 'click');">Test the script</a></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user