473,513 Members | 2,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript and iframe question

Hi,

I'm struggling with the famous "gatekeeper" a little. Normally, it opens
in a popup window, and from there it goes on. But I like this script to
open in an iframe, and not in a popup. It opens with a link.

This is in the main page (where also the iframe):

<script language="javascript">
<!--- begin
var nifty_little_window = null;
function gateKeeper() {
nifty_little_window = window.open('gatekeep.html','theKeeper',
'width=410,height=300,resizable=0,left=0,top=0')
}
// end --->
</script>

So this one opens a popup of course. How to change this so it will open
inside an iframe?

The "gatekeep.html" is this:

<script language="JavaScript">
<!-- Begin
function goForit() {
var location;
var password;
password=this.document.testform.inputbox.value
location=password + ".html"
fetch(location)
theKeeper=window.close()
}
function fetch(location) {
var root;
if (opener.closed) {
root=window.open
('','theKeepersGopher','toolbar=yes,location=yes,s tatus=yes,menubar=yes,
scrollbars=yes,resizable=yes,copyhistory=no');
root.location.href = location;
} else {
opener.location.href = location;
}
}
// End hiding -->
</script>
Is there any way to point the first script to an iframe? It's driving me
nuts! Or should I directly point the second script to the iframe, like
<a href="gatekeep.html" target="MyIframe">click</a> or something and
modify only the second script? Help please. :)

TIA

--
S'fly
Jul 20 '05 #1
6 2582
S'fly wrote:
<script language="javascript">
The `type' attribute is missing for valid HTML 4 and the `language'
attribute is deprecated.
<!--- begin
SGML comments begin and end with `--'. Because they are allowed in SGML
context only and because of an agreement that a JavaScript engine should
ignore the first non-blank line when begins with a SGML comment, you use
`<!' (the MDO -- Markup Declaration Open) here. AFAIK only b0rken IE will
execute scripts despite of invalid SGML syntax.
[...]
// end --->
See above. (The `//' is required only for the script engine not to
interpret `--' as decrement operator, not for ending the SGML comment.)
</script>

So this one opens a popup of course.
Of course not ;-)
How to change this so it will open inside an iframe?


An iFrame is part of the frames[...] collection of Window objects. So the
easy and most compatible way is to name the iFrame by using the respective
attribute and access it via this collection:

window.frames['foobar'].location = "gatekeep.html";

You may need to replace `window' by a reference to a Window object that
contains the iFrame.
PointedEars

Jul 20 '05 #2
On Sun, 09 Nov 2003 20:18:54 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> wrote:
S'fly wrote:
<script language="javascript">
The `type' attribute is missing for valid HTML 4 and the `language'
attribute is deprecated.


The OP doesn't specify a doctype, so you do not know which version of
HTML or XHTML he may be using.
<!--- begin


SGML comments begin and end with `--'. Because they are allowed in SGML
context only and because of an agreement that a JavaScript engine should
ignore the first non-blank line when begins with a SGML comment,


Gibberish - could you cite this agreement?
you use `<!' (the MDO -- Markup Declaration Open) here.
All completely irrelevant as the content-type of SCRIPT is CDATA,
comments are not allowed (well they're not comments, they're just
CDATA) However 3 -, would not be invalid in any case (test if you're
not sure.
AFAIK only b0rken IE will
execute scripts despite of invalid SGML syntax.


There's nothing invalid in the OP's snippet. (or if you assume HTML
4.01 strict then the lack of type existance of language was.)

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #3
Jim Ley wrote:
[...] Thomas 'PointedEars' Lahn <Po*********@web.de> wrote:
S'fly wrote:
<script language="javascript">
The `type' attribute is missing for valid HTML 4 and the `language'
attribute is deprecated.


The OP doesn't specify a doctype, so you do not know which version of
HTML or XHTML he may be using.


If he doesn't specify the DOCTYPE, I assume what a recent UA using a tagsoup
parser will assume: HTML 4.01 Transitional. That's quite generous since a
strict SGML parser will stop(!) when it fails to find a valid DOCTYPE
declaration. The W3C Validator uses the latte parser and you see the result.
<!--- begin


SGML comments begin and end with `--'. Because they are allowed in SGML
context only and because of an agreement that a JavaScript engine should
ignore the first non-blank line when begins with a SGML comment,


Gibberish - could you cite this agreement?


http://www.w3.org/TR/html4/interact/...idx-user_agent
However 3 -, would not be invalid in any case (test if you're not sure.


Input source:

| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
| "http://www.w3.org/TR/html4/loose.dtd">
| [...]
| <body>
| <!---
|
| asfasf
|
| --->

Output of http://validator.w3.org/check (default options)

| This page is not Valid HTML 4.01 Transitional!
|
| Below are the results of attempting to parse this document with an SGML
parser.
|
| 1. Line 55, column 6: invalid comment declaration
|
| --->
| ^
|
| 2. Line 51, column 4: comment declaration started here (explain...).
|
| <!---
| ^
|

The same goes for HTML 2.0 (obsolete) and HTML 3.2, if I let the Validator
ignore my DOCTYPE declaration.

If you think about it, it must be invalid, since if you consider the
second `--' of `<!---' as start of the comment, `<!-' is not a valid
SGML declaration.
AFAIK only b0rken IE will execute scripts despite of invalid SGML syntax.


There's nothing invalid in the OP's snippet.


IBTD. Feed that code to the validator and see for yourself.
PointedEars

Jul 20 '05 #4
On Sun, 09 Nov 2003 21:51:42 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> wrote:
If he doesn't specify the DOCTYPE, I assume what a recent UA using a tagsoup
parser will assume: HTML 4.01 Transitional.
Could you cite an example of any UA which does that, I understood all
UA's just assume tag-soup, as RFC 2854 indicates.
Gibberish - could you cite this agreement?


http://www.w3.org/TR/html4/interact/...idx-user_agent


Doesn't mention anything about the agreement, just illustrates that
some script languages provide such a mechanism, as JS does.
| <body>
| <!---
The example at the content in a SCRIPT element, that is where it would
not be invalid... This is a strawman example.
If you think about it, it must be invalid, since if you consider the
second `--' of `<!---' as start of the comment, `<!-' is not a valid
SGML declaration.
<!-- will "begin the comment" and - will part of the comment.
IBTD. Feed that code to the validator and see for yourself.
<URL:
http://validator.w3.org/check?uri=ht...ne=1&verbose=1


Which is an HTML 4.01 strict page containing:

<script type="text/javascript">
<!--- begin
var nifty_little_window = null;
function gateKeeper() {
nifty_little_window = window.open('gatekeep.html','theKeeper',
'width=410,height=300,resizable=0,left=0,top=0')
}
// end --->
</script>

which is a slightly modified example from the OP - it is valid HTML,
the <!--- and ---> do not denote SGML comments inside of a script
element.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #5
Jim Ley wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
Gibberish - could you cite this agreement?


http://www.w3.org/TR/html4/interact/...idx-user_agent


Doesn't mention anything about the agreement, just illustrates that
some script languages provide such a mechanism, as JS does.


| User agents that don't recognize the SCRIPT element will thus ignore
| the comment while smart scripting engines will understand that the
| script in comments should be executed.

I read this as an agreement since it is part of a specification where
producers of well-known UAs have worked on and their UAs actually obey
what has been specified there.
| <body>
| <!---


The example at the content in a SCRIPT element, that is where it would
not be invalid... This is a strawman example.


At least it proves that /<!---[^-]*--->/ is not a valid SGML declaration
and comment.
If you think about it, it must be invalid, since if you consider the
second `--' of `<!---' as start of the comment, `<!-' is not a valid
SGML declaration.


<!-- will "begin the comment" and - will part of the comment.


You're wrong, as I have already proven. `<!---' is an ambiguous SGML
declaration and therefore not allowed (in parsed content.) Since `--'
opens and closes the comment, adjacent `-'s within comments must occur
in factors of four, or in pairs of two, separated by whitespace or valid
keywords, for valid declarations. Thus /<!>/ is a valid (empty)
declaration, and /<!\w*(\s*--[^-]?.*[^-]?--\s*)+\w*>/ are valid declarations
with comments, provided that /\w/ is a character of a valid keyword.

(FYI: I am currently transforming the online version of a Math resource
book from HTML (with images) to XHTML (with MathML). The author of the
HTML version did not follow the specification in this point which is why
Mozilla/5.0, in contrast to IE, shows a blank page for HTML documents
containing invalid comments, using them as horizontal rules in the source code.)

But as you have stated before correctly, the content *model* (not type)
of the `script' element is CDATA which is not parsed. So `<!---' is not
invalid here. However, a script engine must understand such non-script
character data to parse the script code correctly, and if comes to that,
I rather stick to what has been specified and call the other versions not
recommended.
IBTD. Feed that code to the validator and see for yourself.


<URL:
http://validator.w3.org/check?uri=ht...ne=1&verbose=1
[...]
which is a slightly modified example from the OP - it is valid HTML,
the <!--- and ---> do not denote SGML comments inside of a script
element.


Full ACK.
PointedEars

Jul 20 '05 #6
Jim Ley wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
Jim Ley wrote:
The example at the content in a SCRIPT element, that is where it would
not be invalid... This is a strawman example.


At least it proves that /<!---[^-]*--->/ is not a valid SGML declaration
and comment.


Something, no-one had ever argued with, hence it was a strawman.


Name it as you like, it proves that
<!-- will "begin the comment" and - will part of the comment.

is definitely wrong.
You're wrong, as I have already proven. `<!---' is an ambiguous SGML
declaration and therefore not allowed (in parsed content.)


Comments are not allowed inside SCRIPT, they're just CDATA in
HTML4.01,


They *are* allowed as CDATA but not parsed because the content model.
(FYI: I am currently transforming the online version of a Math resource
book from HTML (with images) to XHTML (with MathML).


Good for you, application/xhtml+xml is a good technology, one that is
very rarely discussed here, as we all live in the text/html real
world.


Obviously you have no clue about MathML which is a valid argument
for using XHTML (otherwise I would not have started to transform
the HTML in the first place.)
But as you have stated before correctly, the content *model* (not type)
of the `script' element is CDATA which is not parsed. So `<!---' is not
invalid here.


Right, so why did you correct the OP on this?


Because I was not aware of the CDATA content model.
Thanks for pointing this out to me.
EOD

PointedEars

Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3203
by: Dany P. Wu | last post by:
Hi everyone, I am trying to create a site with pages containing iframes. This is the first time I've used inline frames and am still struggling with the concept. This site will have 10 pages and so far I have created 20 files, each page having to use a pair of files. One file for the actual page, and one file for the content of the inline...
4
8855
by: PiedmontBiz | last post by:
Greetings I have written an online survey with 110 questions. I use javascript to cycle thru all the questions which are displayed in an iframe. I keep track of the question number using a "global" variable. When testing it, everything works fine until I hit the back button. The iframe goes to the previous question, but of course, the...
4
5493
by: seans | last post by:
Hi, Is there some way from preventing the JavaScript code in a document loaded into an iframe from executing? I don't have access to the pages being loaded into the i-frame so I can't modify then. They are being loaded from a server. thanks again. sean
7
5307
by: unacoder | last post by:
Is it possible to request the user's permission to be able to control IE or FireFox windows that are pointed to domains other than the base domain the script is running from? For example, if my page launches a new window pointing to a web site originating from a different domain, is it possible for my script to request and gain access to the...
8
3625
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
18
43516
by: Chris Ianson | last post by:
Hi geniuses (or is that genii, or genies) The challenge is as above really. I have a page with an iframe in it, and need to call a JS function in the *parent* page, *from* inside the iframe. (It's for Google Maps, but I won't bore you with the complexities of that, as it doesn't affect the question). Mochas kudos to anyone able to...
6
2518
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you get response from a Confirm() popup window to uncheck all server-side checkboxes placed in a panle of a web user control? I am using ASP.Net 2.0, ...
16
1810
by: Phlip | last post by:
Javascripters: I have a page with an iframe inside. Let's say the iframe looks like this: <script src="/javascripts/prototype.js" type="text/javascript" /> .... <iframe id='grinder' src='sample.html' > </iframe> That prototype.js gives us goodies like $(). And sample.html looks a little
15
2232
by: Phlip | last post by:
Javascripters: I have an outer page and an inner iframe. The outer page calculates some javascript, and wants the inner frame to run it. The inner frame should hit a page on the same (private) web server, so this is not a cross-site scripting attack. But I would prefer not to taint the target page with any extra logic to do this. (I will if...
0
7269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.