473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

javascript rookie needs a close-window button

OK. I am halfway decent with HTML. Now I want to try javascript for some
things that HTML cannot do. I have looked over a tutorial & all.

What I want to do is create a button, that when pressed, closes the window
it is in, and launches a URL. The window the button is in is actually just
a sub-page of the main website page, launched with target="blank", but I
just do not want to close the window as I said, I want to launch a website
address from it & have the launched from window close.

So please, walk me through this. Where do I place the:

<SCRIPT language="JavaScript"> ?

(Oh - this is thr right way, correct - case sensitive, right?)

Then what? I can create a button with the tutorials, but if you know, just
write the darned thing for me please - I learned HTML mostly from
copy/pasting.

AND... OK, now more complicated maybe (???). Actually this is more
important than the above. This is from an application sub-page, the page
opening with target="_blank". So the below is HTML that creates buttons.
If the applicant presses the "submit application" button, at least when I
press it, it launches O.E. and asks me if I want to send the filled-in text
through O.E. to the email recipient. You know what I mean, right ? Well,
I want the window the "submit application" button is in to do it's thing all
right - submitting through the email, but I also want the page or window
(I.E. or other?) launched from to close also.

------------ the HTML code that shows two buttons:

<input type="submit" value="submit application">
<input type="reset" value="start over"/><br>

Thanks for your input. Assume I know nothing about javascript, but can get
around in HTML.

...D.
Jul 23 '05 #1
4 2177
....D. wrote:
What I want to do is create a button, that when pressed, closes the window
it is in, and launches a URL. The window the button is in is actually just
a sub-page of the main website page, launched with target="blank", but I
just do not want to close the window as I said, I want to launch a website
address from it & have the launched from window close.
In the popup, you can refer to the opener window with the property
"opener"; before closing your popup, you just have to set the
location.href property of the opener to the new location.

Add the following in your popup:

---
<script type="text/javascript">
//write the close button
//but only if it can be used successfully
if(opener && self.close) {
document.write(
"<input type='button' "+
"value='Close' "+
"onclick='"+
"opener.location.href=\"http://jibbering.com/faq/\";"+
"self.close();"+
"'"+
">"
);
}
</script>
---
<SCRIPT language="JavaScript"> ?

(Oh - this is thr right way, correct - case sensitive, right?)
Javascript is indeed case-sensitive, however the HTML attribute language
is not - and it's actually deprecated, so don't use it, use
type="text/javascript" instead.
If the applicant presses the "submit application" button, at least when I
press it, it launches O.E. and asks me if I want to send the filled-in text
through O.E. to the email recipient.


That's just a "mailto:us**@domain.com" action for the form. However the
technique changes a bit from above:

---
<script type="text/javascript">
function validate(frm){
if(opener) {
opener.location.href="http://jibbering.com/faq/";
}
if(window.close) {
setTimeout("window.close()",1);
}
return true;
}
</script>

<form action="mailto:fo*@bar.com"
onsubmit="return validate(this)">
<input type="text" name="foo">
<input type="submit">
</form>
---

Note that the techniques exposed, while maybe acceptable for a personal
website, would not be used for a commercial one, since they have too
many inherent flaws:
- they rely on popup window, which can be affected by popup-blocking
software,
- they rely on mailto:, assuming that the user has a mail agent
configured (which is not always the case, many people just use web-based
mail agents) - ideally the mail should be built and sent server-side
(google for formmail).
HTH
Yep.
Jul 23 '05 #2
On Fri, 17 Sep 2004 22:15:51 -0700, ...D. wrote:
OK. I am halfway decent with HTML. Now I want to try javascript for some
things that HTML cannot do.
Really? What things?
..I have looked over a tutorial & all.
Well, you have put in the hard yards..
Did you *read* *it*, or just glance
over it?
What I want to do is create a button, that when pressed, closes the window
it is in, and launches a URL.
Pop-Ups.. Your app. is already sunk.

They do work, OK, in some browsers, but
whoever deploys such broken methods must
take special pains to explain to browsers
why your links are not doing anything in
there wonderfully current and up to date
IE with SP 2.

.... So please, walk me through this. Where do I place the:

<SCRIPT language="JavaScript"> ?
Somewhere late last millennium.
<script type='text/javascript'>

You can define functions in the <head>
and call them in the <body>. Actually
you can define methods all over the place,
but it makles most sense to collect them
in one place, either in the <head>, or
in an external file.
(Oh - this is thr right way, correct - case sensitive, right?)


No. JS is generally not case sensitive.

Now, ..given I've been up 28 hours, I better
leave the important stuff for the gurus.

Over and ..snore..

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
Jul 23 '05 #3
Andrew Thompson wrote:
On Fri, 17 Sep 2004 22:15:51 -0700, ...D. wrote:


<--snip-->
(Oh - this is thr right way, correct - case sensitive, right?)

No. JS is generally not case sensitive.

Now, ..given I've been up 28 hours, I better
leave the important stuff for the gurus.


Blame it on the lack of sleep. JS is very case-sensitive. Its the HTML
tags that are not. :-)
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #4
On Sat, 18 Sep 2004 14:04:48 -0400, Randy Webb wrote:
No. JS is generally not case sensitive.
... ..JS is very case-sensitive. Its the HTML
tags that are not. :-)


Aha! Thank you. Personally I allways
use correct case with JS commands (as
well as I understand the nomenclature)
and string comparisons, for the simple
reason it becomes easier for me to read.

Lucky for me (and the OP) you were paying
attention. ;-)

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
Jul 23 '05 #5

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

Similar topics

12
by: Don Bruder | last post by:
A week or two ago, I asked here about porting Python to C. Got some good answers (Note 1) but now I've got another question. Actually, more a request for clarification of a topic that both the...
10
by: William S. Perrin | last post by:
I'm a python rookie, anyone have and suggestions to streamline this function? Thanks in advance..... def getdata(myurl): sock = urllib.urlopen(myurl) xmlSrc = sock.read() sock.close() ...
11
by: Don Bruder | last post by:
Got a stumper here. I imagine that for someone experienced in C++, this is too pathetic for words. For a rookie, using this project as a sort of "midterm exam" in his self-taught "how to program in...
7
by: Marci | last post by:
I found this script for cascading menus, however, I cannot reach the author to solve the bug I am having when I add a second menu to it. My problem is this: If I click on the first link, the...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
2
by: Daveg | last post by:
Hello, Rookie here. I am new at c# and put together a script which is working fine grabbing some elements from an XML file that I created. The problem is that I would like to put at the top of...
1
by: dreamlab | last post by:
Hello, Can one of you javascript wizards help out a newbie, please? I’ve got a formHandler that is supposed to check for a good email address and name in the form after clicking the submit...
27
by: Tom Cole | last post by:
I'm starting to do more quantity of javascript coding and thought this might be a good time to investigate code styling. I primarily develop in Java and currently use the code styling techniques...
3
by: frerejacques | last post by:
Hi, I've encoutered a problem with javascript. I can read and edit basic java. however I'm working on with a free script that I found on the internet and encountered a problem. First I'll...
2
by: asgard0422 | last post by:
i am just starting c++ few weeks ago, and i am facing a matrix problem now. the program has to be built so that the user can select the size of the matrix but it will only be odd numbers.such as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...

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.