I have a website build in php, in some page i show a iframe with another website link, which displays it's login screen.
Both Websites are in different domain.
Like main website : http://www.abcd.com
Iframe href : http://www.xyz.com
Now my users see a page in abcd.com where there is an iframe like
<iframe src="http://www.xyz.com/" style="width:688px; height:384px;"></iframe>
Which displays the login screen of the xyz.com
Now what i want is, if users login to xyz.com another new tab should open with the homepage, after login of xyz.com and abcd.com tab should get close.
Is it possible to do with javascript or jquery, which works for all the browser including IE 7,8,9 ??
Thanks
Open up a new tab
link
linky
pop up
window.open("foo.html", "_blank");
Put the following javascript code in the <head> tag of the homepage of xyz.com (but don't put it in the login page if you still want to keep the login page inside the iframe):
<script type="text/javascript">
if (top.location!= self.location){
top.location = self.location
}
</script>
now, when opening the home page of xyz.com, this code will break the <iframe> and changes the current tab from abcd.com to the home page of xyz.com
i dont know what you mean, but opening a new tab from iframe is just the normal code.
<button>Open New Tab</button>
hope this helps
What you're trying to do is impossible on your end, you only supply a login page inside the iFrame, therefor you cant control what the "login" button actually does, it's controlled by the other website.
The other website will need to edit the action themselves and add target='_blank', but that wont happen as their users will have another tab when they login.
Related
Here's what I'd like to do in Coldfusion:
On a webpage there is a "Download" href link and I want another browser tab to open when the user clicks this link. In the new tab, I am creating a PDF via CFDOCUMENT in Coldfusion. This in of itself works.
However, since the PDF has a delay before it loads in the tab, I want to display a popup to the user that the PDF may take a few moments to load.
So what I tried to do was this sequence:
User clicks "Download" ->
On the same page, I trapped the link with jquery and displayed a popup
window alerting the user there may be a delay ->
User clicks OK on the popup ->
Using javascript window.open, redirected to a new browser window for the PDF.
This was unsuccessful because using window.open in javascript is not trusted by browsers and the new tab doesn't show up because of popup blockers.
So then I thought I'd create a popup in the new browser tab instead before the PDF loads, but discovered I can't use javascript on a page with CFDOCUMENT.
Any ideas as to how to best accomplish this if anything can be done?
I think iframe might be your friend here. It allows you to display another document in the pdf page.
Using your example in the comment, I created two files: one to display the prompt message and one to display the PDF.
cfprompt.cfm
<body>
<div> this is a test </div>
</body>
<cfflush>
<iframe src="pdf.cfm" >
</iframe>
pdf.cfm
<cfdocument format="pdf">
<h1>Hello ColdFusion</h1>
<p>This is <strong>PDF</strong> example document.</p>
<p>Genereated at: <cfoutput>#TimeFormat(Now())# on #DateFormat(Now())#</cfoutput></p>
</cfdocument>
You're still going to have to play with the formatting/sizing of the iframe so that it displays correctly, but hopefully this allows you to display the PDF.
I am creating my portfolio using a Bootstrap template (Freelancer). I have an iFrame embed that displays an e-catalog (located in a pop-up lightbox). For some reason when opening my website on a smartphone device, the page redirects automatically to the fullscreen version of the iFrame website without any prompting or touching. I've tried the 'sandbox' tag and it does not seem to work, but perhaps I am using it wrong. To clarify, the site/iFrame embed loads fine on desktop, but on mobile it redirects the homepage.
This is the iFrame code:
<iframe src="http://www.zoomcatalog.com/catalogs/kts-spring-2014/" width="100%" height="630px" frameborder="0" scrolling="no"></iframe>
The website is http://www.danieltomasku.net
Do I need to add some JavaScript to prevent the window from opening automatically? If so, how do I implement this? Should 'sandboxing' have worked? Should I put a div around the iFrame?
Any help would be appreciated. Let me know if you need more info/code. Thank you.
The site you are opening contains the following:
var iRegex = /android|(iP(hone|ad))/i;
if(iRegex.test(navigator.userAgent)){
var url= "<...>" + window.location.hash;
if(true) top.location=url; else window.location=url;
}
This JS redirects the parent page (your page [top window]) to another URL if the useragent matches android/iphone/ipad.
Just make it a linked static image. Otherwise you'd need to write a script to detect the location change attempt and override it. Besides, the iframe is messing with the framed page's analytics, counting each page view on your site as a view for the framed page.
Love the site by the way.
I have a website where I HAVE to link to another website, this other website contains this code:
if (parent.window.opener) parent.window.opener.location='http://AdvertisingURL';
if (self.parent.frames.length!=0) self.parent.location=document.location;
The link on my site is a normal link with target=_blank, when I click on it, the site containing that code opens in a new windows, and then my website gets redirected to the advertising URL.
How could I block that redirection without any alert message?
I have an ASP.NET 3.5 intranet website which has a default page with a menu and when the user clicks on a menu item, I display the page for that menu item in an iframe embedded within the default page. but if the user types the URL of a page directly in the browser, then I would like to redirect him to the default page, because all the content pages do not have a menu. (Master Pages will solve this issue, but I can't use Master page here for a reason and don't want to go into those details). how to find out if user has arrived at the page directly by typing the URL or by clicking on the menu item, so that I can decide whether to redirect or not? Is this possible to find out? btw this is an intranet site and no login is required. thanks in advance.
put this in your frame (or frame master page):
<body onload="CheckTop()"></body>
<script type="text/javascript">
function CheckTop()
{
if (window == window.top) window.location = //topurl, pilot page
}
</script>
You should use MasterPages for your problem, beacuse iFrames are not a good technique.
But, you could try it with a litte JavaScript-Snippet in the content pages:
<script type="text/javascript">
if (top == self)
window.location = "/index.html";
</script>
You simply check, if the loaded page is identical to your iFrame. If this is true, then your iFrame is loaded directly.
I have a question on javascript window management.
My application opens an iframe which displays a link. Clicking on the link, opens a popup window, in which I enter my login credentials. My intention is to close the popup window after the login credentials are entered. And this I have been able to achieve using a JS call to self.close().
There after my server side script does some more processing and would like to display the results back in the iframe. This is where things break for me.
The overall flow is as follows:
Iframe Displays a Link --> Clicking on the Link Pops up a window --> Popup Window closes after credentials are entered --> I see my original iframe now (How do I display the contents back in the iframe). Here is the code snippet that closes the popup.
5
6 self.close();
7
The parent of the popup is the iframe. If I modify the above script to give the focus back to its parent, which in my case will be the iframe, will that suffice? Or am I issing something here?
you can access the iframe from your popup by using opener. for example this will reload your iframe:
<script type="text/javascript">
opener.location.href = "htp://mypage.com/myiframe.php";
</script>
you just have to add the right parameters to show what you want to. (of course you have to do this before your self.close();)