Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

In one of my project i have an iframe where product images are displayed. When user will click the images a pop up will open to view the large size of image. Here I am using jquery colorbox(http://www.jacklmoore.com/colorbox/[^]) for the image pop up.

The problem is i want the pop up to be open in the browser window, but currently it opens inside the iframe.


Please help...........

Thanks
Swarup
Posted

You can't do that. As it is a modal popup, it will always open inside the IFrame.

You can open an window using window.open(), so that it will open over the current browser window. But that will not help you I guess.

So, you have do something like below.

-> Open this image from parent window not IFrame.
-> For that you can call the function of parent like
JavaScript
window.parent.MyFunction(dataToSend);

Here MyFunction is defined inside parent window.
And dataToSend is the data you want to send to parent.

-> Now according to the data, just invoke this modal popup image inside that MyFunction.

Can you implement this ? Give it a try.
Feel free to ask any doubts. We will discuss.

[Update]
For Permission denied issue
This issue comes, when the IFrame and the Parent form are in different domain.
We can also fix this.
I have written one tip for this.

You can refer - Communication with Cross Domain IFrame - A Cross Browser Solution[^].

Please try this and let me know.
 
Share this answer
 
v2
Comments
swarup sahu 6-May-13 1:32am    
Hi,

Thanks for your replay:)

I tried this. Now i am getting error in FireFox permission denied to access property 'MyFunction'. :(. In other browsers, it is also not working

Any idea?

Thanks
Is the IFrame in different domain ?
We can fix this.
Check my updated answer.
swarup sahu 6-May-13 5:11am    
Hey tadit,

I appreciate your answer. But I dont think, i can get access to all property of colorbox in this way(like grouping of images for next and previous button).

So I am doing this by div instead of iframe. Lets see what happens.

Thanks again
Oh ok. But just get all the data you want to send to Parent and then just do a window.postMessage() to send all the data and open that required modal, can't it be possible ? You don't need to access anything from either of Parent or IFrame, you just need to communicate or pass the data.

Anyway, as you are trying with div, just try... That will be good.
 
Share this answer
 
Hi Swarup,
Did you try with 'target' attribute for your child window inside the 'iframe'.
Ideally we have blank, parent, self and top. If you use either blank or top to the subwindow with in iframe it opens as new window. Pls check this once.

Thanks,
Ravi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900