留言板

Open new link on iframe from another portlet

din sim,修改在12 年前。

Open new link on iframe from another portlet

New Member 帖子: 4 加入日期: 11-7-1 最近的帖子
I have two Portllets left and right, left Portlet links to different ages and fight one if iframe Portlet when a link is clicked on left it needs to display the page inside iframe, http://www.liferay.com/community/wiki/-/wiki/Main/Iframe+Portlet this page suggests pass URL through anchor element (like http://localhost:8585/web/guest/home#http://www.google.com) but this needs page refresh,is there any other way to achieve this without page refresh or any other options

Thanks
thumbnail
Leo PRATLONG,修改在12 年前。

RE: Open new link on iframe from another portlet

Expert 帖子: 363 加入日期: 10-7-6 最近的帖子
On the onclick, you can change the "src" value of the "iframe" tag with a piece of javascript code.

<script type="text/javascript">
    function changeIframeSrc() {
        document.getElementById('uglyIframe').src="http://www.liferay.com";
    }
</script>

<a href="#" onclick="changeIframeSrc();return false;">Click me!</a>

<iframe id="uglyIframe" src="">Your browser blablabla...</iframe>


And, to make it better, you can try to not use iFrame and you can try to make it with Ajax (if it's possible in what you are trying to realize).