We have a customer portal site hosted externally.
I need to create a page in our company site where in employees will use the page to login to the portal. The login page they offer is generic
To implement this, I am planning to create a page and then iframe (width: 200px ; height:100 px) the login page of the customer portal. This way I can have the company branding on the login page..
But my problem is, when user logs in via the iframe, the resulting home page opens within the iframe window.
My question: is there a way to find the url of the page that is loaded in the iframe so that based on the url, I can change the dimensions of the iframe?
The src attribute of iframe always shows the login page url.
My Iframe code:
<iframe onload="loadMyFrame();" src ="https://login.tomyportal.com" width ="370" height="200" id="sWindow" frameborder="0"></iframe>
<script type="text/javascript" language="javascript">
function loadTest() {
var ifr = document.getElementById("sfWindow");
alert(ifr.src); //the value returned is always login page.
}
</script>
how about
alert(ifr.location.href)
?
Related
I'm using ASPX web pages (WebPage1.aspx) and have an HTML iFrame defined in this page. I dynamically define the iFrame src (via code behind) when my ASPX web page loads ... all good so far.
The web page that gets loaded into my iFrame supports a "ReturnURL" that I've defined when I set the src for the iFrame. Something like:
src = "https://www.someothersite.com/Somewebpage.aspx?ReturnUrl=http://www.mywebsite.com/WebPage2.aspx"
The web page (Somewebpage.aspx) has a "Return" button, the user clicks the Return button and they should get redirected back to the "ReturnURL" I specified (http://www.mywebsite.com/WebPage2.aspx).
What happens is http://www.mywebsite.com/WebPage2.aspx gets displayed in my iFrame on http://www.mywebsite.com/WebPage1.aspx. This IS NOT what I wanted, I wanted to simply be return to http://www.mywebsite.com/WebPage2.aspx.
Is there a solution to this problem within the context of ASPX and code behind?
Cheers, Rob.
Hey all thx for your time!!.
I want to add a login page at my website. So, i am using iframe and centered it to show the username,password and connect button. But, i want my page to load the iframe page when user click the connect button inside the iframe.
First, i want them to add the username and password info. And click load, then the page reloads but keeps their info (i hope).
Here is the code
<iframe id="iframe" scrolling="no"
src="http://sms.altasoft.gr/panel/index.asp?lang=el&disp_function=user_login&id=5E8A0F4B-063B-4A7A-81FE-99579AF44BAA">
<p>Your browser does not support iframes.</p>
</iframe>
If the page loaded into the iframe uses some cookies to keep the log in information, this should work:
<script type="text/javascript">
window.onload = function(){
var iFrame = document.getElementById("iframe");
iFrame.onload = function(){
window.location = iFrame.src;
};
}
</script>
If I understand correctly, you're using an iframe and want to have the main page reload when the form inside the iframe has been submitted. Is that correct? If so, add ' target="_top"' to the form inside the iframe, and it should reload the whole thing.
On browser back button click i want to redirect to a Custom Page that i create,
Example: In most banking applications while transacting if you click browser back button you get Page expired page and from there you can provide some links to login again.
the below code only prevents form navigating to previous page
<script type = "text/javascript" >
function disableBackButton() {
window.history.forward();
}
setTimeout("disableBackButton()", 0);
I am using DotNetNuke, could you provide any solution for this.
You can include that in a custom Module on every page of your website, or you could embed your JS into the SKIN for your website in DNN.
I had a page(Home.aspx) containing menu on the top and another master page, with same menu on the top.
Now, when i have to move from Home page to master page, i use
window.location = 'test.aspx';
Now, when i need to move from master to main(Home) page, i need to call a function with a parameter, containing control url, which has to be loaded to the iframe in the Home page.
Can anybody suggest how can i load Home page and iframe within simultaneously using javascript.
If you don't want the user interact with the page until the iframe is loaded, you can disable the page with javascript (onLoad of the page <body onload="disablePage()">) and enable again when the Iframe is loaded (onLoad of the Iframe <iframe onload="enablePage()"... )
Here some post about disable or gray out page: CSS/JavaScript Use Div to grey out section of page
I have created a Facebook app to house my site within an iframe.
At every request I want to check that the site is inside the Facebook app, otherwise I want to redirect the user to the Facebook app.
I can check that I am within an iframe with javascript:
if (top != self)
But I don't know if I'm actually inside the Facebook app.
The cross-domain security hinders me from accessing the parent document's info. For example, "top.location.href" cannot be accessed.
Can someone help me out? :-)
Facebook attaches a value to window.name so you can use JavaScript to check.
if(window.name.indexOf('iframe_canvas_fb') != -1){
// in Facebook
} else {
// not in Facebook
}
You can check FB.Canvas namespace methods from facebook's javascript library. It will work on Facebook canvas.
https://developers.facebook.com/docs/reference/javascript/FB.Canvas.getPageInfo/
check what info do you get while in the facebook's iframe, outside iframe or in another iframe.
hope this helps
Well if the user is outside of Facebook this bit of script before the body html tag should redirect them back to your page on Facebook:
<script language="JavaScript" type="text/javascript">
<!--
if (self == top) {
window.location = "http://apps.facebook.com/YOUR_APP_PAGE";
}
-->
</script>
remember to change the 'YOUR_APP_PAGE' bit to something like:
'my-application?app_data=page-location'
you can send the request ?app_data to your Facebook page using php and append the page that your website was redirected from so that the app_data can tell your app to load this page but within Facebook.
So it is worth looking up Facebook app_data
If you want to change the style of your page depending if it is displayed on Facebook or not then use this:
<script language="JavaScript" type="text/javascript">
<!--
if (window.self = "http://apps.facebook.com/") {
var element = document.getElementById('html');
element.className = "facebook";
}
-->
</script>
and modify your html tag with the id=html like so:
<html id="html" xmlns:fb="http://www.facebook.com/2008/fbml">
this will allow you to use a class name .facebook remap any style for your page that you like.
If you need to set some initial php settings like the redirect page, then you can use this code in php to detect if you are within Facebook, however this code can not detect if the user is on Facebook or not after they have logged in:
if(!empty($_POST['signed_request'])){
//do something with php here...
}
Note:
It is unlikely the Facebook user on your app page has JavaScript turned off which is why we can use the above php code to set redirects etc...
php should not really rely on $_SESSION or cookies for this in case the user decides to visit your page having logged in to your Facebook application, it would take a page refresh for php to determine that they are no longer in Facebook from the session or cookie.
After thought:
All this information should be on the Facebook SDK's as managing redirects and application detection is a nightmare with Facebook's horrific documentation.
Hope this helps you out :)