Solved

Break out of an Iframe

Posted on 2012-04-05
9
411 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…

760 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

18 Experts available now in Live!

Get 1:1 Help Now