Solved

Break out of an Iframe

Posted on 2012-04-05
9
415 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to change pointer icon to hand icon on mouseover 2 19
Exit the loop 4 35
using php variable inside javascript 5 14
Gridview alignment 1 10
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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now