I just put the doc link in a iframe a with prev/next buttons I want to control.
So the idea is to simulate key press : 'n' for next and 'p' for previous
Code: Select all
<html>
<head>
<title>Slides viewer</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#prev").click(function() {
pressKey(112);
});
$("#next").click(function() {
pressKey(110)
});
});
function pressKey(code){
console.log('press='+code);
var evt = document.createEvent("KeyboardEvent"); // or KeysEvent
evt.initKeyEvent("keypress",true,true,null,false,false,false,false,code,code);
// Send to label
var myLabel = document.getElementById('myLabel');
myLabel.focus()
myLabel.dispatchEvent(evt);
// Send to slides
var slides = document.getElementById('slides');
slides.focus()
slides.dispatchEvent(evt);
}
</script>
</head>
<body>
<input id="prev" type="button" value="<"/>
<input id="next" type="button" value=">"/>
<input id="myLabel" type="input" value=""/>
<iframe src="https://docs.google.com/present/view?id=0AX5OB7HMRFTQZDR3czVwal8yMjdmdG0zOTljOQ" id="slides"
width="100%"
height="100%"
scrolling="auto"
frameborder="0"
/>
</body>
I put a label just to verify events are well.
When I click on buttons, the label is fill but the slides don't change. However, if I just press 'n' or 'p', it's work because the iframe have focus.
Any idea ?