By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,939 Members | 1,621 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,939 IT Pros & Developers. It's quick & easy.

a problem with iframes

P: 49

I want to put an iframe (or a frame) in a page on my website, with the content in the iframe coming from another website. But I want the entire page to reload when (1) anyone clicks on any link in the iframe, and (2) anyone clicks on any button (after submitting a form) in the iframe.

Then why am I using an iframe? Well, that is a channel on my site being powered by the other site. So the look and feel should be mine, but the block in the iframe comes from them.

Is there any way to do this?

I had an idea (actually this idea was in another site, it's not mine) that I could put all my content in frames too (header, right side ad and footer), and write a JavaScript function like this that I would get the other site to put in the HTML of all its content that appears in the iframe:

function doThree(pageA,pageB,pageC)

and get every hyperlink on the other site look like this:

<a href="whatever" onclick="doThree('newpage1.html','newpage2.html',' newpage3.html')">ONE LINK changes all frames</a>

The hassle is, they might crib about having to recode a zillion <a href> tags. So is there any way that this could be done in the CSS of the other site itself, by making every hyperlink (anchor tag) automatically run that onclick function, so that I do not have to worry about the manual effort of re-hardcoding several <a href>s, and the missing out that might happen?

I would really, really appreciate any pointers - either a solution to what I asked, or a completely different approach altogether :).

Again, I would want the frames belonging to my content (as opposed to the frame containing their content) to reload even when someone clicks on a submit button.

Thank you for reading this through!
Jun 13 '07 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 15k+
P: 16,027
Welcome to TSDN!

So you want the website to reload and ignore the URL in the href attribute?
Jun 14 '07 #2

P: 49
Welcome to TSDN!

So you want the website to reload and ignore the URL in the href attribute?
Yes, that's right. I actually did it (thanks to <a href="">help</a> - for the benefit of other people who need to do this, here is how:

Expand|Select|Wrap|Line Numbers
  1. var loaded = 1;
  2. function loadMyPages(pageA, pageB, pageC)
  3. {
  4.    if (loaded>1){
  5.          window.frames["frame1"].location.href = pageA;
  6.          window.frames["frame2"].location.href = pageB;
  7.          window.frames["frame3"].location.href = pageC;
  8.    }
  9.    loaded++;
  10. }
  12. <iframe src="" onload="loadMyPages('newpage1.html','newpage2.html','newpage3.html')"></iframe>
  14. <iframe name="frame1" src="mypage1.html"></iframe>
  15. <iframe name="frame2" src="mypage2.html"></iframe>
  16. <iframe name="frame3" src="mypage3.html"></iframe>
Jun 15 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.