load page and iframe simultaneously through javascript - iframe

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

Related

Stuck in iFrame, how to get out?

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.

how to prevent loading aspx pages in single page asp.net website

I developed a single page website (like windows 8 tiles) and i put my aspx pages in iframe when i click a tile in default page it opens the related iframe in same default page. Its all working fine.
Here the problem is when default page is loading all the iframe aspx pages are loading it is unwanted and there it takes lot of time to load all the pages, it is not necessary to load the pages when i click the tile then the related iframe page will open.
How did i prevent this loading aspx pages ?
A possible way around this would be to leave the src attribute of each iframe empty and use javascript to change it on click.
For example, you could create an iframe like
<iframe id="ifrm" src=""></iframe>
and add to the tiles an onclick event with the following javascript:
document.getElementById['ifrm'].src = "http://www.test.com";

Navigating away from page referenced using iframe

What I have at the moment is a page which I am using as a sirt of site master for my html pages. The way I am doing this is by referencing the master page using this line of code:
<iframe scrolling="no" style="width:100%;" frameBorder="0" src="WebForm1.aspx"></iframe>
Now that works fine, I can create a new page and reference that, and then the content from that page will appear on any page referencing it.
But I have a problem, what I want Is if you click the navigation button that is in header of a page that is referencing this site master; it navigates away but only the iframe will hold the webpage, and the main content will still be the same.
For example:
In the master page I am referencing using the Iframe, I have some code that when you click on a button it navigates away, ok. But if I go into a page that is referencing the master and click the button, the new web page will only open in the iframe section at the top of the page.
Sorry for this complicated question, if anyone understands it, then any advice would be helpful!
The page that is referencing the master:
http://codepad.org/IyrDxAf9
The master page itself:
http://codepad.org/XMu67H1M
PS...I am coding this in asp.net using html
The aim of all this is to create a master page for html, but I am not having much luck with it
You can set the following in your webform1.aspx page:
<base target="_parent" />
This will target all the links on that page to the 'parent' window. You can also do this with individual links.
Seeing as you are using .aspx pages here, is there a reason why you are not using the built in master page functionality?

How to avoid refreshing of masterpage while navigating in site?

In my website, I have created a masterpage and attached all of my pages to it.
My masterpage structure contains a header and a footer. On the left it has a treeview control, which i have attached to all my pages, and on the right there is a contentplaceholder to show the content of respective pages.
My problem is that when I click any link in the treeview it refreshes the whole masterpage and open the respective page. I wish to avoid this refresh. Means it should show the contents of page on right side contentplaceholder without refreshing the whole page.
I have seen people suggesting to use iframes. But for using iframes I shall have to restructure my website. Is there any other solution than iframes and with minimal changes to the work that I have done?
You will probably want to look at using AJAX to stop this from happening. You will want to read up on using an UpdatePanel. Below are some good articles that goes over this:
http://geekswithblogs.net/ranganh/archive/2007/05/11/112405.aspx
http://msdn.microsoft.com/en-us/library/bb399001.aspx
You also have the option of using jQuery to handle your AJAX calls. While I typically prefer the use of jQuery when using AJAX, I am not sure I would use it in your situation. If you would like to look at what it offers take a look at these links:
http://api.jquery.com/jQuery.ajax/
http://sixrevisions.com/javascript/the-power-of-jquery-with-ajax/
You could put the content you wish to change inside an asp:UpdatePanel that way that will be the only thing that is repainted (it uses AJAX under the hood):
http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.aspx
The master page class derives from the UserControl class and the master page is like a child control. So we can say that master page is not a true page, when a page loads we can notice the navigation URL in the address bar is the content page's but not the master page! so we cannot refresh a content page without refreshing master page.
there is one way to avoid flickering the page by adding the code in < Head > section in the masterpage.
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0)"/>
<meta http-equiv="Page-Exit" content="blendTrans(Duration=0)"/>

How to get the url of the page which is currently loading in the iframe

I have an requirement that, in my application on clicking an button I have to load one more application with the same template which I was using for my application.
So, on clicking the button in my application I have used one intermediate page in that using iframe I passed that URL of an external application. Its working fine.
But the problem is in the external application which is not in my control on clicking an button it is moving to next page. In that page I want to hide an button.
I did that also using div tag color as white and set the positions.
But the problem is in all the pages in the same position that is affecting. So I want to get the URL of the page which is loading in the iframe on the second or third click of an external application, so that I can using some conditions I can hide the control.
You can use Javascript. Give the iframe an ID
var iframe = document.getElementById(id);
The url is accessible via the "src" attribute:
iframe.src
more info

Resources