?
Solved

Break out of an Iframe

Posted on 2012-04-05
9
Medium Priority
?
435 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

840 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