function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lopezclopezc 

how to redirect my window parent from an iframe?

Hi,

I need to display a VF page on the home page (I am overwriting the task component). For this I have  create a HTML homepage component and use the iframe tag pointing the src attribute to my VF page, to make this I use an s-control. Example:

Code:

<IFRAME src="/apex/myTasks" width="100%" height=400 frameborder="no"> </IFRAME>
 
However I have a problem with this. In my VF page a have a buttom "new" to be able to create a new Task. But because I am in an iframe the new page is download in the iframe. I have tried with this:

Code:
<apex:commandButton onclick="JavaScript&colon; parent.location.href ='/00T/e—retURL=%2Fhome%2Fhome.jsp';" value="New" id="theButton"/>

 
But when I click on the buttom it doesn't do anything, I am always in the same page.Any ideas?

Thanks!



Sam.arjSam.arj
Why not using the good old INPUT html tag?

Code:
<input value="New" id="theButton" class="button" 
onclick="javascript&colon;parent.location.href ='/00T/e—retURL=%2Fhome%2Fhome.jsp';"/>

 I think this should do, right?




Message Edited by Sam.arj on 09-22-2008 08:51 AM
lopezclopezc
Hi,

Thanks for your fast reply! I tried to do what you sujested but when I click on the input an error message is displayed in the console:

javascript is not defined

Do you know what is happening now?
Sam.arjSam.arj
You remove the javascript part and just keep the actual code there. It Should still work.

Let me if works.
lopezclopezc
Hi, At the end the input should be written like that and it is working:

Code:
 <input value="New" id="theButton" class="button" onclick="parent.parent.location.href ='/00T/e—retURL=%2Fhome%2Fhome.jsp';"/>

 Many Thanks Sam!

ovadbarovadbar

You can do it like explained above iff the iframe is under the same domain as the main page otherwise look into 

/support/api/{version}/interaction.js

There is a screenPop method that does this.

Documentation  can be found in the open cti documentation.

 

Note: I have had problems with this if the iframe is reloaded when the main page hasn't been by changing the iframe src value. 

 

Thanks

Baroukh Ovadia