Cannot get parent window - javascript

Hi I have the following problem:
I open an url in an iframe:
<iframe name="framenamex" id="frameidx"
<a href="urlx.." target="framenamex">..xxx..
then I want to hide the iframe from the iframe:
<div onclick="javascript:parent.document.getElementById('frameidx').style.visibility='hidden'">
but it does not work, it seems like this frame has no parent, because when i call parent.location or window.top.location I get nothing.
please help. thanks in advance.

Related

Hide a div on embed tag

I have an embed tag on a site with an external source.
I'd like to hide a div on the external source that I'd like to hide.
The embed code is this:
<embed src="https://www.site.com" width='100%' height='1000px'/>
And the div has a class and inline style
<div class="button" style="display:block !important;">
Is it possible to hide with javascript or CSS?
I know that I can't do it with an iframe for security issues, is it the same with embed tag?
Or do I have other ways to do that?
First, define ID for both control as:
<embed id="embedID" src="https://www.site.com" width='100%' height='1000px'/>
<div id="divID" class="button" style="display:block !important;">
After that write below code:
$("#embedID #divID").remove();
Try this:
document.getElementsByClassName('button')[0].style.visibility='hidden';
This may help you.
Give the button an ID. For example: button1
<div class="button1" style="display:block !important;">
$("#button1").remove();
or
$("#button1").hide();
if you want to define multiple ID's at once, you can use:
$("#button1 #button2").remove();
or
$("#button1 #button2").hide();
Both should work!
For external links like you mentioned in the comments:
Using JQuery you should be able to exactly that with the load-function. Here is a small example to get a container with id "container" on a page called Test.html:
$('#contentDiv').load('/Test.hmtl #container');
You can visit the JQuery documentation here for more info

Iframe don't fits JQuery UI dialog

When I try to open a URL using Iframe in a dialog JQuery box, I got this: http://s15.postimg.org/7qzx5y8vv/Sem_t_tulo.png
Here is my code: http://pastebin.com/Wqf0mGhZ
I want to make the dialog shows ALL the content, thanks...
EDIT:
Hey guys, I achieved this by putting the iframe in a div tag, like this:
<div id="imgWindow" title="this is a dialog" style="display:none;">
<iframe width="100%" height="100%" id="iframeImg" marginheight="0" frameborder="0>
</iframe>
</div>
I didn't go through all of your code, but maybe you
can just add autoResize call to open callback (on Dialog):
function openDialog(stringURL) {
$("#imgWindows").attr("src", stringURL);
$("#imgWindows").dialog("open", {
callback: function() {
autoResize('imgWindows');
}
});
}

Want to place a button to close the iFrame, but button click is not working

In my meteor based application i am using an I frame to show some contents to the user. It is working properly. But i want to place a close button which unloads the Iframe from the template when clicked.
I tried it as in the code given below by placing a button, but I am unable to get click event on it. means button click is not working. I am working with iframes for the first time.
Is this the right way to unload an iframe?
If not then how can i unload it, or what is the best way to unload an Iframe?
<template name="preview">
<div style='display:none'>
<div id='preview' style='padding:10px; background:#fff;'>
<button id="close_content_file">Close</button>
<iframe frameborder="1" src="{{preview_url}}" align="left" width="100%" height="500px" >
</iframe>
</div>
</div>
Template.preview.events({
'click #close_content_file':function(){
console.log(" previev butoon has been clicked");
$("#preview").fadeOut();
},
});
I placed a <button></button> in the div to close or unload the Iframe. but click is not working on that button.If I place the button in the div which is hidden. The button is working there. Iframe is opening on the complete screen. means it over lays the omplete screen as bootstrap modal dialogbox.can i place a button in the Iframe itself? . help will be appreciable
There is an issue with the binding of event with the button. Use this way.
$("#close_content_file").bind("click", function() {
//console.log(" previev butoon has been clicked");
$("#preview").fadeOut();
});
I don't know which JS lib you are using, and also I'm a little confused about the
<div style='display:none'>
but I make a little modification so it works fine with jQuery ,
here is the link http://jsfiddle.net/QHxac/

add images from popup to parent page

I written a simple image editor PHP script, users can add images from galleries to editor area and merge all finally.
now my problem is:
galleries open as popup and editor area is parent page, i need a javascript or jquery code when a user clicked on a item in popup page, image added to parent page in specific div.
here is destination div code:
<div id="objects">
<div class="obj_item"><img id="obj_1" class="ui-widget-content" src="elements/1.png" /></div>
<div class="obj_item"><img id="obj_2" class="ui-widget-content" src="elements/2.png" /></div>
</div>
please help me,
thanks
You can target the parent using window.opener
$('#objects', window.opener).append('image code');

how to change a div from an iframe in another div

I have two divs
<div id="leftdiv"><!--#exec cgi="test.cgi"--></div>
<div id="rigthdiv" >
<iframe name="rigthdiv" class="contentiframe"allowTransparency="true" frameborder="0" src="iframebg.html"><body STYLE="background- color:transparent"></iframe>
</div>
I am trying to change the leftdiv from iframe. I called the js below from the iframe but nothing changed. What's wrong? Thanks
function test() {
parent.document.getElementById("leftdiv").innerHTML = 'Processing complete.';
}
It won't work on chrome, but it can work on firefox or IE. Chrome doesn't support iframe normally when you use javascript. You can try to use JQuery.

Categories