How can I force swf files to be run, not downloaded - javascript

For example, I want to make an iframe to this url: http://example.com/game.swf
The problem is, users who are on different browsers/devices/settings have the issue where instead of running the swf, the browser is just downloading it.
Keep in mind, I don't have access to the code for http://example.com, or the fla file. I need to use the iframe hack because of some issues with the swf.

The iframe must load an HTML file, instead of directly loading some SWF file. So get around that rule by embedding SWF within the same html that the iFrame will be loading.
If iframe has code:
<iframe src="http://example.com/game.html"> </iframe>
Then in game.html have code:
<!DOCTYPE html>
<html>
<body>
<embed src="http://example.com/game.swf" width="800" height="600">
</body>
</html>

Related

js/jquery - How to change existing iframe attribute from inside the iframe

I am working with TFS and I'm trying to upload an extension(web page) to the dashboard.
When the dashboard loads my extension it wrapps my it with Iframe.
TFS Iframe example
The iframe sandbox attribute missing the allow-same-origin which allow me to manipulate the page that contains my extension.
Is there a way to change the iframe attribute from my extension web page?
the whole page looks like:
<html> // Tfs page
<body>
<div> // main page
<iframe sandbox='allow-scripts ...'> // the iframe that wrapps my extension, missing 'allow-same-origin'
<html> // my extension
<body>
...
</body>
</html>
</iframe>
</body>
</html>
Thanks...
I think this is on purpose: you should use the SDK to interact with VSTS/TFS, otherwise it is easy to imagine a rogue Extension that sells a company's Intellectual Property in the deep web.

Show the PowerPoint presentation in web page using html

I trying to display my ppt with long time where the screen should run continuously in web page where the file is in my local folder but it is not showing in web page. The code is below :
<!DOCTYPE html>
<html>
<body>
<iframe src="lp.ppt" width="800px" heigt="600px" name="iframe_a"></iframe>
</body>
</html>
can anyone help to display ppt in html page.
You can use Google Docs to serve as your document viewer. You just need to upload your file and use the share link as the iframe src.
You can get the embed code by uploading your file and opening it in google docs (in this case, Google Slides) then click the file tab and click the Publish to the Web. From there you can copy the embed code. Make sure that the file is public! :)
<iframe src="https://docs.google.com/presentation/d/17nlO95lz91-shRep16UiJl-3EAxv-MnOFH718ku2gtw/embed?start=false&loop=false&delayms=3000" frameborder="0" width="960" height="749" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>
<iframe src="https://docs.google.com/presentation/d/17nlO95lz91-shRep16UiJl-3EAxv-MnOFH718ku2gtw/embed?start=false&loop=false&delayms=3000" frameborder="0" width="960" height="749" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>
Hope this helps!

refresh iframe from a .php in a separate iframe

I have a page that is built with 7 different iframes:
<iframe id="leftframe" src="structure/leftbar.php"></iframe>
<iframe id="headerframe" src="structure/header.php"></iframe>
<iframe id="menuframe" src="structure/menu.php"></iframe>
<iframe id="timerframe" src="structure/times.php"></iframe>
<iframe id="settingsframe"></iframe>
<iframe id="contentframe" name="contentframe"></iframe>
<iframe id="chatframe" src="chat/index.php"></iframe>
I have a .php that is being run in the "contentframe". When I click a button in it, it sends a post to a .php. The .php functions properly but at the end of it, I want it to reload the leftframe frame.
I tried the suggestions on these pages:
How to refresh an IFrame using Javascript?
What's the best way to reload / refresh an iframe using JavaScript?
but neither of these seem to work.
in the .php I am trying:
?>
<script>
parent.getElementById('leftframe').location.reload();
alert("Ping");
</script>
<?php
This doesn't work either. Any suggestions?
Thanks!
Using back-end to refresh an iframe when you can do it client-side is absolutely wrong.
It works for me:
<script>
document.getElementById('leftFrame').contentWindow.location.reload();
alert('Ping');
</script>
And, yes, are you sure you need iframes?
It is definitely not a good practice. Especially, in a century of powerful JS and its frameworks and AJAX. It would be better if you updated the content of DOM element instead of refreshing iframe.

iframe accessing child JavaScript of source

I have been trying to access a html source file through iframe. It works fine and I can see the source, but my external JavaScript file doesn't work through the iframe.
So far this is what I have for accessing the HTML file.
<iframe src="Example.html">
<p>Your browser does not support iframes.</p>
</iframe>
and then in Example.html I have:
<script src="SpinScript.js"></script>
This works if I run the HTML file in any browser, but not through the iframe
In this HTML file I have other JavaScript elements but they are just written in this document and they work fine through the iframe.
What I'm wondering is if have to re-establish where the JavaScript file is in the iframe?
Hope that all makes sense and thanks for your time.
Your parent window and iframe should be from the same source (url),
then you can use
window.frames[framename] to get window object in iframe

How to change the src of an iframe to an embed src within an iframe?

This may sound a bit confusing at first but I will try to explain. I am trying to access the code of an embed tag playing a youtube video inside an iframe and have it change the src on an outside iframe when the inner embed container is clicked.
note:the external frame is a full website in the background of the myframe player. myframe is a mock video player.
heres the basic way the document is set up
<body>
<iframe id='myframe' src='something.htm'></iframe>
<iframe id='externalFrame' src='external.htm'></iframe>
</body>
//external.htm
<body>
<embed id='mediaPlayer' src='somethingElse.htm' >
</body>
external javascript
var myPlayer=document.getElementById('myframe');
var externalFrame=document.getElementById('externalFrame');
externalFrame.contentWindow.document.getElementById('mediaPlayer').onclick=function(){
var mediaPlayer=externalFrame.contentWindow.document.getElementById('media_player');
myPlayer.src=mediaPlayer.src;
}
For the record I hate iframes with the passion of 1000 suns, and would never use them usually but for this the media player has to keep playing when the page changes. and Iframes are good for mimicking that.
That should work fine just make sure that the link to the src is directed to the correct place in the structure.

Categories