Solved

Break out of an Iframe

Posted on 2012-04-05
9
416 Views
Last Modified: 2012-04-10
Experts,

I have  a website on which I have an Iframe. A third party vendor loads in to my Iframe. My user will interact directly in the iframe , the user in puts are validated by the third party vendor only. Upon validaiton completion I need to break out of the iframe. Please suggest me an idea how I can accomplish it.

Thanks
0
Comment
Question by:SubbuUSA
  • 5
  • 4
9 Comments
 
LVL 5

Expert Comment

by:onlyaymie
ID: 37811806
0
 

Author Comment

by:SubbuUSA
ID: 37816401
@onlyaymie

Thanks for your reply. However I need some more help.

Is there a way I can pass a URL as a parameter from the onload or onclick function call to my javascript breakoutiframe () to get redirected to the desired web page
<html>
<head>
<script type="text/javascript">

function breakout_of_frame(var paramurl1)
	{
          if paramurl1 contains cc
	    redirect to cc page';
          else
          redirect to main page
	  return true;
	}
}
</head>
<body >
Authentication successful Verified your Identity. <tri:Lnk SiteUrl="CreditCenter" target="_top">click Go to CC </tri:Link> to go to CC 
<br/>
<div style="text-align:center;padding-bottom: 20px;">
<tri:InputImg OnClick="javascript:breakout_of_frame([b]paramurl1[/b]);" class="finished" name="SaveChanges"  src="CC /buttons/btn-gotoCC .gif" alt="Go To CC " DisableOnSubmit="true"/></td>

</body>
</html>

Open in new window

0
 
LVL 5

Expert Comment

by:onlyaymie
ID: 37823486
Is your html page that has the javascript an ASP (or other server side programming) page or just a static html page?
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:SubbuUSA
ID: 37823916
@ onlyaymie

No it will be a content file that I need to redirect..which takes control and renders the appropriate *.aspx page. Before redirecting I need to break out of the javascript .


<html>
<head>
<script type="text/javascript">
function copyText(url, f1,f2)
{
document.getElementById("field2").value=document.getElementById("field1").value;
alert(url);
//Break out and rediret to credit.aspx

}
</script>
</head>
<body>

Field1: <input type="text" id="field1" value="Hello World!" /><br />
Field2: <input type="text" id="field2" />
<br /><br />
<button onclick="copyText('credit.aspx','hi1','hi2');">Pass values1</button>

</body>
</html>
0
 

Author Comment

by:SubbuUSA
ID: 37823923
Or the function copytext() needs to be called from body onload()...either way I am fine. I would prefer body onload.

anyhelp on this would be greatly appreciated
0
 
LVL 5

Expert Comment

by:onlyaymie
ID: 37829079
I think this does what you are asking for...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script>


(function(window) {
  if (window.location !== window.top.location) {
    window.top.location = window.location;
  }
	window.location = "http://google.com";
})(this);

</script>
<title>Untitled</title>
</head>
<body>

</body>
</html>

Open in new window

0
 

Author Comment

by:SubbuUSA
ID: 37829217
@onlyaymie

thanks for your response. As a band aid I was able achieve my functionality like the code below. However I need to take decisions to which page it should go based on the query string  parameters in go_now() function like u. Please let me know your thoughts.

<HTML>
<HEAD>
<TITLE>Automatic Redirection to Credit Center</TITLE>
<script type="text/javascript">

function redirect () 
{ 
setTimeout("go_now()",100); 
}
function go_now ()   
{ 
top.location = "http://www.google.com"; 
or 
top.location ="www.yahoo.com"; // need to achieve this functionality based on decision statements
}

</script>
</HEAD>

<body onload="redirect()">

</body>
</HTML>

Open in new window

0
 
LVL 5

Accepted Solution

by:
onlyaymie earned 500 total points
ID: 37829367
something like this?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script>
(function(window) {
      
  if (window.location !== window.top.location) {
    window.top.location = window.location;
  }
      alert(window.location.search.indexOf('blah=blah'));
      alert(window.location.search);
      if (window.location.search.indexOf('blah=blah')>-1) {
            window.top.location = "http://google.com";
      } else {
            window.top.location = "http://yahoo.com";
      }
})(this);

</script>
<title>Untitled</title>
</head>
<body>

</body>
</html>
0
 

Author Closing Comment

by:SubbuUSA
ID: 37830325
Thanks appreciated
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question