Setting IFrame size from within the IFrame - javascript

I've been trying a few things like the following trying to get the iframe to be reset from within the iframe but I am not sure what I am doing wrong. Ideas?
window.top.$("#ID").width(324);
window.top.$("#ID").height(369);
Has not worked.

Related

how to trigger a method in javascript when contents of iframe changes with src of iframe remains same

I have recently started working on YUI JS and Wicket. I am facing a problem and couldn't solve it for the past few days.
Here is the problem: Am using an iframe in my wicket application. I have to resize the iframe based on its content changes using YUI. Here the problem is when the content changes, still src of the iframe remains same. I tried by adding listeners to the elements of the iframe but I was unsuccessful. Please help me out in this. Thanks in advance.

When to call Javascript for ScrollHeight

I have a page with an iframe. The two sites (parent site is php, child site is asp.net 2.0) are on different domains, although I control both of them. Most of the work is done within the iframe. I am using the postMessage function to send information about the total height of the content in the iframe. However, it always comes up as 0, I guess because the script executes before everything is laid out on the screen. Is there a way I can obtain the total height (I think it's scrollHeight, right?) of the child site so that I can send it to the parent?
Thanks!
so you want the parent to adjust the size of iFrame when you got o another page etc.. so suppose your using jquery as the JS lib you can try this trick. in the parent.html do this
$(document).bind('atriggerMessage', function(e) {
//do the iframe size change or other stuff
});
then within the iframe you need to trigger the event. so in the iframe.html
parent.$(parent.document).trigger("atriggerMessage");
I wanted to post my solution in case someone else comes across the same issue.
I ended up putting javascript code in the html markup almost right before the closing tag. This ensured that the page was visible before the body.scrollHeight was called. I don't understand why the body.scrollHeight inside window.onload() or body.onload or $(document).ready() as #shakirthow said above.

jQuery Copy text inside iframe to main document?

Hopefully someone here can help me with this challenge!
I have a parent page which is the checkout page for an e-commerce site. It's run on zencart and for every order placed a table row is generated through ZenCart. I've setup an EACH function which generates an iframe for an artwork uploader for each TR (order) found. The uploader works and the correct number of instances are being generated.
I wanted to avoid an iFrame, but the uploader script I purchased will not permit me to load it directly into the zencart page template, or via AJAX (tried both). There's some kind of major resource/path situation going on when doing it this way... so I've resorted to iframes.
I'm able to call JS on file-upload-complete. At that point I'm trying to capture the name of the filename that was just uploaded and place it inside the TR. The problem I'm running into are permission error when trying to access the iframe contents.
I've tried everything I've come across on this site and many others, so believe it isn't a problem with the selectors/frame selection... Firebug is telling me that I'm getting permission errors when trying to access the iframe, yet they're both on the same domain and the src is being set by a relative path....
I'm completely lost, any suggestions would be appreciated! Thanks!
www.prothings.com/store
Add items to the cart and go to checkout.....
when you want to access main window or window.document from inside an iframe you should change the context by using window.parent
For example when you want to append some text to a div, you should do something like this
window.parent.$.('#theDiv').text('the text');
There is a bug in IE when you run the code from inside the iframe and remove the iframe in between. IE can't run the code in the fly

Javascript top.location.replace with and without parent iFrame

I am using a frames page, which contains the following Javascript line:
top.contentsFrame.location.replace("/main.jsp");
I want to run this page both inside an iFrame, as well as independenty.
In an iFrame it doesn't work, because the top attribute now returns the iFrame. So it can't find "contentsFrame" anymore.
What would be the easiest way to fix this?
Cheers!
you should use
parent.top.location.replace("/main.jsp");

Load javascript before Iframe

In this page: http://www.depositosalto.com.br/lojas.php, I have a javascript to resize a div and a iframe containing a google maps location. Happens that the javascript is executed only after the iframe is loaded. How I do to the javascript be executed first?
EDIT: The javascript is not to resize the iframe, but another div with the content with id = "conteudo".
You can calculate the proper size of the IFRAME and then generate the IFRAME tag using JavaScript. This will guarantee that your IFRAME will appear only after JS code executed.
P.S. Use tag to make sure that people who has JavaScript turned off will still see the IFRAME with Google Map.
Use the <body onload: > option. This triggers when the page is first loaded.

Categories

Resources