473,977 Members | 4,148 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="javas cript">
<!--- begin
var nifty_little_wi ndow = null;
function gateKeeper() {
nifty_little_wi ndow = window.open('ga tekeep.html','t heKeeper',
'width=410,heig ht=300,resizabl e=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.h tml" is this:

<script language="JavaS cript">
<!-- Begin
function goForit() {
var location;
var password;
password=this.d ocument.testfor m.inputbox.valu e
location=passwo rd + ".html"
fetch(location)
theKeeper=windo w.close()
}
function fetch(location) {
var root;
if (opener.closed) {
root=window.ope n
('','theKeepers Gopher','toolba r=yes,location= yes,status=yes, menubar=yes,
scrollbars=yes, resizable=yes,c opyhistory=no') ;
root.location.h ref = 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="MyIfram e">click</a> or something and
modify only the second script? Help please. :)

TIA

--
S'fly
Jul 20 '05 #1
6 2609
S'fly wrote:
<script language="javas cript">
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*********@we b.de> wrote:
S'fly wrote:
<script language="javas cript">
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.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #3
Jim Ley wrote:
[...] Thomas 'PointedEars' Lahn <Po*********@we b.de> wrote:
S'fly wrote:
<script language="javas cript">
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*********@we b.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_wi ndow = null;
function gateKeeper() {
nifty_little_wi ndow = window.open('ga tekeep.html','t heKeeper',
'width=410,heig ht=300,resizabl e=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.javas cript 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
3223
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 frame. It sounds bloody silly to me but then again I am only a beginner at web
4
8889
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 counter is not decremented. Example if I am at question # 5 and I hit the back button, I go to #4,...
4
5520
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
5339
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 content of that window, and be able to control the window?
8
3693
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
18
43598
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 solve this widdle.
6
2537
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, Thanks. Need info...
16
1869
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
2295
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 I must.) The calling page has these elements:
0
10356
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10172
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
11581
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7617
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6418
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
5160
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3764
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.