Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Markup (HTML, XHTML, XML) _ Load a Frame from a URL

Posted by: ckm Sep 6 2018, 08:29 PM

I have a 3 frame website in which one frame contains a menu of blog articles that load in a difference frame when clicked on. I'd like to address the website via a URL that loads one of the blogs initially. Can this be done, and how?

Thanks
ckm

Posted by: CharlesEF Sep 6 2018, 10:36 PM

Well, once you have the page loaded copy the URL and paste it into a blank window to test.

Posted by: Christian J Sep 7 2018, 04:12 AM

That's not possible, see http://htmlhelp.com/faq/html/frames.html#frame-address and http://htmlhelp.com/faq/html/frames.html#frame-problems

Posted by: pandy Sep 7 2018, 05:34 AM

Depends on what the OP means.

Do you want this blog to always be loaded when people go to your frames page or only when you use a "special" URL?

I want to add that if those blogs aren't your own, it isn't exactly polite to frame other people's sites.

Posted by: ckm Sep 7 2018, 09:08 PM

I'd like to use special URLs that load specific blog pages (mine) into the main frame. By default it loads the first on the list but I'd like to pass URLs to clients in emails that load a specific blog.

Posted by: pandy Sep 7 2018, 11:18 PM

I think this is possible with JavaScript. By adding a query string to your URL, have JS read that query string and load the corresponding page. What say you, Christian?

There may be a little time lapse though. Never tried this, but I would expect so.

Posted by: pandy Sep 8 2018, 12:40 AM

I tested a little. Lets say your frameset looks like this.

CODE
<frameset cols="30%,70%">
   <frame name="menu" src="menu.html">
   <frame name="content" src="content.html">
</frameset>



Put a script block in HEAD of you frameset document with this.

CODE

function loadIt()
{
   var whatSite = window.location.search;
   whatSite = whatSite.replace("?site=", "");

   if (whatSite == 'htmlhelp')
      window.frames['content'].location = 'http://htmlhelp.com';
}

window.onload = loadIt;


Let's say your URL is http://example.com . If you access it with this URL http://example.com?site=htmlhelp then htmlhelp.com should load in the content frame. That is, you add a query string to the end of your URL in the format ?name=value.

You'd need to change the so it uses your name of the frame where the page should load and uses what you choose as querystring. And if you want to be able to load different sites this way you need to build on the if else a bit.

Posted by: Christian J Sep 8 2018, 04:57 AM

You can also just use different static frameset files for each combination (no javascript needed). Making different frameset files is not more work that adding to the javascript whitelist of pages.

Beware of making a javascript that works automatically with any querystring (pandy's doesn't), that would save some work but also opens up the frameset to cross site scripting. Possibly you could make it only work for pages on your own domain. unsure.gif

Posted by: pandy Sep 8 2018, 05:30 AM

That's true. Didn't think of that. cool.gif

Also, I made a critical typo in the query string in the mockup URL above. Corrected now.
(I wrote ?=htmlhelp instead of ?site=htmlhelp)

Posted by: ckm Sep 13 2018, 01:54 AM

Thanks Christian and Pandy! Those suggestions helped.
I got it working.

Posted by: hojiwar Oct 20 2018, 09:06 AM



$("#button").click(function () {
$("#frame").attr("src", "http://www.example.com/");
});

HTML:

<div id="mydiv">
<iframe id="frame" src="" width="100%" height="300">
</iframe>
</div>
<button id="button">Load</button>

here online web programming tutorial https://www.welookups.com

Posted by: Darin McGrew Oct 20 2018, 04:34 PM

QUOTE(hojiwar @ Oct 20 2018, 07:06 AM) *

$("#button").click(function () {
$("#frame").attr("src", "http://www.example.com/");
});

HTML:

<div id="mydiv">
<iframe id="frame" src="" width="100%" height="300">
</iframe>
</div>
<button id="button">Load</button>

here online web programming tutorial https://www.welookups.com
This doesn't really address the issue the OP asked about.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)