Forums de discussion
Change URL dynamically inside an Iframe
Sofia Lucas, modifié il y a 9 années.
Change URL dynamically inside an Iframe
New Member Publications: 13 Date d'inscription: 12/06/14 Publications récentes
Hello,
I need to change dynamically the URL of an Iframe in Liferay 6.2 . In Liferay's wiki, they exposed the method of concatenating the new url of the iframe with the URl of the page
but it didn't work for me.
Do you have any idea about other methods ?
I need to change dynamically the URL of an Iframe in Liferay 6.2 . In Liferay's wiki, they exposed the method of concatenating the new url of the iframe with the URl of the page
http://localhost:8585/web/guest/home#http://www.google.com
, but it didn't work for me.
Do you have any idea about other methods ?
Sofia Lucas, modifié il y a 9 années.
RE: Change URL dynamically inside an Iframe
New Member Publications: 13 Date d'inscription: 12/06/14 Publications récentes
Any idea please ? I searched for the reason why it doesn't work for me , but I didn't find anything .
Pankaj Kathiriya, modifié il y a 9 années.
RE: Change URL dynamically inside an Iframe
Liferay Master Publications: 722 Date d'inscription: 05/08/10 Publications récentes
Just appending url after # wont help, you have to refresh the page then iframe will take url appended after #.
Sofia Lucas, modifié il y a 9 années.
RE: Change URL dynamically inside an Iframe
New Member Publications: 13 Date d'inscription: 12/06/14 Publications récentes
@pankaj , Thank you . But even with refreshing the page , it doesn't work
Pankaj Kathiriya, modifié il y a 9 années.
RE: Change URL dynamically inside an Iframe
Liferay Master Publications: 722 Date d'inscription: 05/08/10 Publications récentes
Have you tried window.location= url to refresh the page?
Sofia Lucas, modifié il y a 9 années.
RE: Change URL dynamically inside an Iframe
New Member Publications: 13 Date d'inscription: 12/06/14 Publications récentes
Yep, I did. But it's not working neither . It seems to be a problem related to the version of Liferay , I mean "6.2" .
Sofia Lucas, modifié il y a 9 années.
RE: Change URL dynamically inside an Iframe
New Member Publications: 13 Date d'inscription: 12/06/14 Publications récentes
What I decided finally is creating a Js script that has access to the Iframe of my page , and changes its sourceUrl with a new value .
Frederic Bonin, modifié il y a 9 années.
RE: Change URL dynamically inside an Iframe (Réponse)
New Member Publications: 6 Date d'inscription: 23/06/11 Publications récentes
Hi,
I had the same issue, I looked at the source /portal-web/docroot/html/portlet/iframe and debugged and found out that they added a new feature to set the iframe location to a specific iframe. Thus, the syntax changed.
Before :
http://localhost:8585/web/guest/home#http://www.google.com
After
http://localhost:8585/web/guest/home#<portletID>=http://www.google.com
Example : http://localhost:8585/web/guest/home#_48_INSTANCE_K6cmhmmeKqB9_=http://www.google.com
I had the same issue, I looked at the source /portal-web/docroot/html/portlet/iframe and debugged and found out that they added a new feature to set the iframe location to a specific iframe. Thus, the syntax changed.
Before :
http://localhost:8585/web/guest/home#http://www.google.com
After
http://localhost:8585/web/guest/home#<portletID>=http://www.google.com
Example : http://localhost:8585/web/guest/home#_48_INSTANCE_K6cmhmmeKqB9_=http://www.google.com
Sofia Lucas, modifié il y a 9 années.
RE: Change URL dynamically inside an Iframe
New Member Publications: 13 Date d'inscription: 12/06/14 Publications récentes
Thank you for this relpy . Actually, I made a JS script , and it's working fine:
// Getting the iframe
var iframeTag= window.frames[0];
// Getting its source url
var x = iframeTag.location.href;
// Making some operations to build the new url
var pos = x.lastIndexOf('/');
x=x.substring(0, pos);
var url = window.location.href; //This is the url of the whole page
if(url.indexOf("?") >0 ){
var argumenturl= url.substring(url.indexOf("?")+1);
x=x.concat(argumenturl);
// Putting the new url in the Iframe
iframeTag.location.href=x;