Added a basic scriptapi with a test page.

Signed-off-by: retep998 <retep998@verizon.net>
This commit is contained in:
retep998 2013-04-04 12:53:57 -04:00
parent 3ecea83687
commit 7c059424de
2 changed files with 27 additions and 2 deletions

View File

@ -1,3 +1,14 @@
function script_click_a(url) {
window.location.href = url;
function script_fire_event(element, type) {
//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
View 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>