PDA

View Full Version : DHTML Window problem



VatsaL
04-25-2006, 12:16 PM
hi, I used a DHTML window(http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow.htm) on my website. The problem is, that the page on which i've placed the link to launch a DHTML window is a page which appears inside an <iframe>, so beacuse the size of the DHTML window needs to be slightly larger than the <iframe>, its sides get hidden and you cant close/control the DHTML window due to this. Changing the sizes od the <iframe> or DHTML window dosent help, as i need them to be of a specific size. I tried posting the main part of the DHTML script outside the <iframe> which i discovered, didnt work. Any idea, on how I can launch the Dhtml window OUTSIDE the <iframe> despite its launch link being INSIDE the <iframe>? I cant provide you with the actual page adress, as i'm still building the website and have not hosted it yet. please help!

thanx


VatsaL

anonymouse
04-25-2006, 10:02 PM
Are you launching the dhtml window using a link or does it load automatically?
I don't know if this will work, but a simple suggestion--if you are loading with a link--would be to try to add a target to a different frame. Using the example code:

<a href="javascript:loadwindow('http://www.google.com',600,400)" target="main">Google</a>
That way the link will load in "main," rather than the iframe, since the default target is something like "_self"

jscheuer1
04-26-2006, 09:05 AM
Put the script on the top (parent) page, then use for the link inside the iframe:


<a href="javascript:parent.loadwindow('http://www.geocities.com',600,400)">Geocities</a>

Twey
04-26-2006, 03:46 PM
Ych, no.
<a href="http://www.geocities.com" onclick="parent.loadwindow(this.href,600,400);return false;" target="_blank">Geocities</a>That way non-JS browsers won't barf on the link, and should even still open it in a new window.

jscheuer1
04-26-2006, 04:05 PM
Ych, no.
<a href="http://www.geocities.com" onclick="parent.loadwindow(this.href,600,400);return false;" target="_blank">Geocities</a>That way non-JS browsers won't barf on the link, and should even still open it in a new window.

Well, it depends. If you want that behavior, yes. However, if the content to be displayed in the DHTML window would be better off being skipped in browsers without javascript enabled, the link example I provided (modified from the demo page's example) would be preferred.

This could also be accomplished in better fashion:


<a href="plain_content.htm" onclick="parent.loadwindow('enabled_content.htm',600,400);return false;" target="_blank">Link Text</a>

Where plain_content.htm is a substitute page for non-javascript enabled browsers and enabled_content.htm is a similar page that relies heavily upon javascript.

However, if you truly wanted nothing to happen in non-javascript enabled browsers, the original code I provided would still be the way to go.

So, there is no reason to get so excited. Yes, there are various ways, depending upon the outcome desired.

Twey
04-26-2006, 04:09 PM
I'd disagree; if one wanted nothing to happen in non-JS browsers, it's a better idea to use "#" or even the widely-implemented "javascript:void(0);". Using javascript: may cause ugly errors if the link is selected.

jscheuer1
04-27-2006, 05:13 AM
I'd disagree; if one wanted nothing to happen in non-JS browsers, it's a better idea to use "#" or even the widely-implemented "javascript:void(0);". Using javascript: may cause ugly errors if the link is selected.

"#" is a bad idea. That will reload the page and if the link isn't in the top portion of the page, scroll the page to the top. On Geocities (and perhaps other) sites, the consequences can be even worse, see this thread (http://www.dynamicdrive.com/forums/showthread.php?t=7262). Your second idea is a good one and is very much the same as what I suggested there. However, though possible, it is highly unlikely that the javascript:parent.loadwindow('http://www.geocities.com',600,400)" will cause problems. If it would, javascript:void(0) might also.

Twey
04-27-2006, 06:36 AM
"#" is a bad idea. That will reload the page and if the link isn't in the top portion of the page, scroll the page to the top.Not if JS is enabled and one uses return false. On a non-JS browser, yes, it is likely to happen, but that's better than a large "Javascript not supported" error.
However, though possible, it is highly unlikely that the javascript:parent.loadwindow('http://www.geocities.com',600,400)" will cause problems. If it would, javascript:void(0) might also.I'm lead to believe that javascript:void(0) is commonly recognized as "do nothing" by browsers, JS and non-JS alike. In this case, it should not cause a problem, since the Javascript is never actually executed.

jscheuer1
04-27-2006, 06:53 AM
(about using "#") Not if JS is enabled and one uses return false. On a non-JS browser, yes, it is likely to happen, but that's better than a large "Javascript not supported" error.

I know that "#" can cause problems with javascript enabled and return false. It shouldn't, but it does on some servers. That is what that thread linked to (http://www.dynamicdrive.com/forums/showthread.php?t=7262) in my last post highlights. I've seen it happen other times as well. It may be a Geocities only thing and is probably due to server added scripts but, Geocities is widely used and if they do it, others could/may do it as well.

I'm just not convinced that javascript:void(0) is that different to most browsers in non-javascript enabled mode than any other otherwise valid javascript: prefixed code used as an href. It may be, I just haven't studied it that thoroughly or run across it that much. Whenever I have, it didn't seem to present any problem.

Twey
04-27-2006, 10:49 AM
That thread would seem to illustrate a problem with return false from anchors in general, not anything specific to href="#".
I haven't studied this thoroughly either. I shall research it in detail at a later time tonight.

jscheuer1
04-27-2006, 02:10 PM
That thread would seem to illustrate a problem with return false from anchors in general, not anything specific to href="#".

Quite. At the same time, making "#" not the best choice for this sort of thing. I've often thought it a poor choice in general though, except for something like:


<a href="#" onclick="window.scrollTo(0, 0);return false;">To Top</a>

On Geocities, even that would be a bad idea because you get 'charged' for each page load. On free accounts, this counts toward monthly (or whatever the cycle period is) limits. This server added script in question on Geocities seems to invalidate or cancel return false for onclick events.

Twey
04-27-2006, 03:04 PM
I've had a look at this, and in links, at least, javascript:void(0) is not treated specially. I concede the point.