Open custom URL in iframe when page loads

I’m looking for an action (or a piece of JavaScript) that helps me solving the following problem:

There is a page containing an iframe element. This iframe has a default URL to open when calling the page’s URL, e.g. www.me.tld/page.html .

Now when calling an URL with attributes, e.g. www.me.tld/page.html?load=www.othersite.tld it should load that custom URL into the iframe instead of (I know that the URL must be URL-encoded, but it’s just an example :slight_smile: .

Do you have any hint for me ?

Thanks,
Tobias.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Now when calling an URL with attributes, e.g. www.me.tld/page.html?load=www.othersite.tld it should load that custom URL into the ifram

Use the Target attribute on the link to tell the browser where the result of the link should go. The iframe Action has a field where you enter the name of the iframe, use that as your target.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Waltd,

but the target attribute only works when actually opening a link within the same frameset (same page), doesn’t ?

However I look for a solution that enables me to type in an URL like http://www.me.tld/page.html?load=www.other.tld into the URL bar of the webbrowser and then get www.other.tld loaded in a particular iframe on that page.

Here is a real-world example of what I want to achieve:

There is an iframe on this page named “contents”. How can I open a different URL than the default one at that iframe by calling above URL ?

Tobias.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This thread should help you;
http://www.dynamicdrive.com/forums/showthread.php?t=12512

Regards,
Tim.

On 16 Apr 2010, at 21:42, tobiaseichner wrote:

Hi Waltd,

but the target attribute only works when actually opening a link
within the same frameset (same page), doesn’t ?

However I look for a solution that enables me to type in an URL like http://www.me.tld/page.html?load=www.other.tld
into the URL bar of the webbrowser and then get www.other.tld
loaded in a particular iframe on that page.

Here is a real-world example of what I want to achieve:

TOBIAS EICHNER IT + CONSULTING - Information Technology Is Our Universe !

There is an iframe on this page named “contents”. How can I open a
different URL than the default one at that iframe by calling above
URL ?

Tobias.

FreewayActions.com - Freeware and commercial actions for Freeway
Express & Pro.

Protect your mailto links from being harvested by spambots with Anti
Spam.
Only available at FreewayActions.com

http://www.freewayactions.com


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks for the hint… I think it’s what I’m looking for, but must dive in more carefully tomorrow (it’s midnight here and the JavaScript reads like Chinese at that time :wink:

Do you think this might also work when used in conjunction with forms ?

I would have a “search box” on one page and want to get the results (search engine output) shown on a different page containing an iframe.

For technical reasons I cannot use a “template” that search script could use to get a custom layout. So that’s why I thought about the iframe solution.

Tobias.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This thread should help with targeting iframe on different page.
http://www.freewaytalk.net/thread/view/29208#m_29957


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I think I’ll go a more unconventional way… how does the following concept sound to you ? Are there any problems to expect ?

Page “Origin” contains a search box where the user types in a string to look for. The form is caught by a JavaScript function that first URL encodes the form input and then stores it in a cookie. After this has been done, the target URL (“Results”, containing the iframe) is opened.

Page “Results” contains a JavaScript function that - upon page load - looks for an existing cookie. If no cookie is found, a default URL is called for the iframe.

If a cookie is found, the value is read out and merged with an URL template, e.g. http://www.me.tld/cgi-bin/something.pl?query=cookie_value_url_encoded . Then the cookie is deleted (to prevent people revisiting that page will get undesired results). Finally the URL containing the custom search query is opened at the iframe.

So far my theory…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I solved it finally this way:

The form on the first page (GET method) calls the destination page; this way, I’m able to hand over the desired parameters to the destination.

The destination page contains the iframe opening a default URL unless there is custom data within the URL. In this case, it extracts the parameters and opens a different URL within the iframe.

I haven’t tested it much yet and it’s a very special application. But maybe useful, so I share it with you…

Also if you find some bugs or have some improvement suggestions (or questions about using it), let me know as well.

The source is at TOBIAS EICHNER IT + CONSULTING - Information Technology Is Our Universe ! (copy&pasting it here destroyed the formatting).


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Actually i am doing this,
protected void Page_Load(object sender, EventArgs e)
{
String URL = http://www.aspforums.net/;

          if (!String.IsNullOrEmpty(URL))
                {
                    
                    I1.Attributes["src"] = URL;
                }

}

Displaying correctly,But Moble ,Tablets Not displying correctly.plz correct my code


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

The runat=“server” is the issue here. If you are trying to reload an iframe in response to a click on the page without reloading the page, then the script has to run in the browser, not on the server. Try something like this:

<iframe id="foo" src="about:blank"></iframe>
<a href="http://www.apple.com" target="foo">Apple</a>

That doesn’t need any script to work at all.

If you want to manipulate the src attribute in response to something else running in JavaScript in the browser, then the proper way to access that attribute and manipulate it is like this:

<script type="text/javascript">
var iframe = document.getElementById('foo');
iframe.src = 'whatever you want here'
</script>

You can also use JavaScript in the page to reload an iframe in response to a change in the browser’s URL, by reading and interpreting the search and hash portions of the window.location attribute. This can give you a magic iframe that will load a different remote document depending on a querystring or anchor attribute in the URL.

Finally, you may be running afoul of the load order of the page. When searching for an item in the page by its ID, it is critically important that the script either appear after that item in the page’s source code order, or that the script include a built-in timer that waits until the entire document has loaded (jQuery’s ready() and Protoype’s document.observe(‘dom:loaded’) callbacks, respectively).

Walter

On Oct 23, 2013, at 8:11 AM, anil wrote:

Actually i am doing this,
protected void Page_Load(object sender, EventArgs e)
{
String URL = http://www.aspforums.net/;

         if (!String.IsNullOrEmpty(URL))
               {

                   I1.Attributes["src"] = URL;
               }

}

Displaying correctly,But Moble ,Tablets Not displying correctly.plz correct my code


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options