iframe accessing child JavaScript of source - javascript

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

Related

How to load html file into article content?

I download an extension from freefrontedit and upload it on my server to directory /accordeon.
When I point the browser to http://mysite/accordeon/index.html it works well.
But how could I load the index.html into article content?
I am using joomla template.
I try with <iframe src="http://mysite/accordeon/index.html" width="100%" height="100%"></iframe> but then the height is not same.
Is there other way to load accordeon/index.html into an article?
I wonder how this custom extensions can be used in cms like joomla and wordpress without iframe your own content because iframe height is never the same as the source. Pasting index.html code in article content works only when they dont have index.HAML file because neither article neither custom html module could understand HAML code and just display it as plain text

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

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>

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.

XUL iframe firefox addon, how to change the src within the iframe?

I am developing a firefox addon,
in my settings page dialog.xul i have an iframe where i load different settings pages page1.xul page2.xul page3.xul
Iframe :
<vbox flex="1">
<iframe
id="iframe"
src="chrome://xxx/content/page1.xul"
flex="1"></iframe>
</vbox>
Within the iframe i need to navigate from page2.xul to page3.xul
with the code in page2.xul
My code (page2.xul) :
gBrowser.loadURI("chrome://xxx/content/page3.xul");
Also tried
document.getElementById("iframe").setAttribute("src", "chrome://xxx/content/page3.xul");
but it's not working i know iframe container is not accessible from the iframe but how can i do that redirection ?
With iframe in XUL you must create it with the HTML namespace otherwise things like load events don't work right, see this topic: http://forums.mozillazine.org/viewtopic.php?f=19&t=2809781&hilit=+iframe
Once you do that, changing src etc should work as expected.
Solution :
I managed to handle the code in the main XUL
Apparently XUL does not support the structure
[XUL1 >> iframe(XUL2 : change something in XUL1)]
This structure is not supported in classic HTML + Javascript for security reason
and it's also the case in XUL

PDF calling twice in IE

I am facing an issue with PDF loading in my page.
I am using object tag to embed PDF,
<object data='addDocs.do?viewName=PDF&id="+$("#pdfId").val()+"&File=regDoc.pdf' type='application/pdf' width='95%' height='750'> </object>
This is getting called twice when using IE Browser.
I did some search on the same question and tried with response.setDateHeader("Expires", 30000);. No Luck.
I can't use IFRAME because I need to open the links inside the PDF in the same window rather than inside IFRAME.
When using EMBED tag to load PDF, If the size of the PDF is larger then browser is freezing.
So, please help me out on calling PDF only once in IE.
Thanks in advance.

Categories