-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to control my embedded Sozi form outside the <iframe> as described in the documentation #680
Comments
There is an important difference between your code and the tutorial. window.addEventListener("load", function () {
...
}, false); Have you tried this? I suspect that your script is executed too early. It tries to access |
Thank you very much for responding Guillaume - great spot - obvious now you've pointed it out but many thanks for helping me to move this on. I have managed now to get my NEXT frame external button working perfectly as is demonstrated here very convincingly but for some reason that I cannot explain, the PREVIOUS frame button fails because JavaScript is reporting...
Which cannot be right because I'm pretty sure the function exists in the player. Here is the full code with plenty of
If anyone can spot the problem, I'd be very grateful - I'm ALMOST there! |
I was also pretty sure it existed until I checked. Can you try this simple change and tell me how it works for you? var player = frame.contentWindow.sozi.playerController; |
That's it - 100% fixed! Here is my first successful embedded Sozi in action; there will be more. |
Summary of your problem or feature request
I cannot seem to control my embedded Sozi form outside the <iframe> because Javascript cannot 'find' the 'player'...
I am Sozi 23.07.25-1690311612
I use a drawing program called Xara Designer Pro+ but I include that info here purely for compliance as there is no problem with SVG itself.
Steps to reproduce the problem
Understanding the guidance on embedding
I have read and understood the guidance (https://sozi.baierouge.fr/pages/tutorial-embedding.html) on communicating with a Sozi when it is embedded in an an IFRAME and below is the <iframe> that I am using to embed my Sozi...
<iframe id="sozi-frame"src="https://sirclickalot.co.uk/assets/books/gcse-computer-science-plus/chapters/computer-systems/topics/introduction-to-computer-systems/journeys/the-basic-computer-system-process-breakdown/braille-to-english-landscape.sozi.html" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>
This all seems to work exactly as expected.
Why have I given the <iframe> an ID?
You will notice that I have given the <iframe> an ID of 'sozi-frame'.
I initially tried to target the iframe exactly as described in the guidance but got no joy there either so rather than simply target the 'first' <iframe> in my out Javascript, I chose to be more specific by using...
var sozi_frame = document.getElementById("sozi-frame");
I can 'see' this <iframe> in my Javascript perfectly fine - the ULR is public so anyone can try it out.
Here is the full tweaked version of my javascript - I am not interested in the Sozi frame titles so mine is slightly cut down from the guidance example...
NOTE the crude but illustrative
alert()
on the third line - we never reach this point because the value ofsozi_player
isnull
.The Javascript console reports...
Uncaught TypeError: Cannot read properties of undefined (reading 'player')
I am at a loss here, can anyone please help me to see what I'm missing?
Why does my
sozi_player
frame appear to be missing its.player
?Resources for anyone who can help
HERE is the working HTML that tries to target the 'player' using the grey
btnNext
andbtnPrev
at the bottom right corner.HERE is an archive of my Sozi for reference.
Thanks all, getting this solved will open the doors to me using and promoting Sozi widely in our open source education project so I would be very grateful for any advice given.
The text was updated successfully, but these errors were encountered: