473,499 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Basic Javascript scenario: best practice??

bj
I have several pages that I want to allow the same kind of activity,
so my basic question is how best to structure the interaction (and I
have one related subquestion as well).

Scenario: The user clicks a hyperlink and opens a new window in which
there is a bit of explanatory text. This text will be different for
every link. In addition, there is an image on the page which can be
clicked to close the new window.

(This image should rollover on mousing over and out of the image: I
haen't been able to make this work yet; help?)

I would like to pass the text, and the necessary window size (just big
enough for the text)to be used to a common function that I can use
over and over again by calling that function when the user clicks the
link. And I need to be able to have the Close image have rollover
capability when the new window opens.

I don't want to creat an html doc for this and call it if that is at
all possible.

The code I have used is below, but it's too clunky and cannot be
reused easily:

function rollImages(){
if (document.images){
changeClose = new Image;
simpleClose = new Image;
changeClose.src = "../../../../../Generic_Images/close_over_v2.gif";
simpleClose.src = "../../../../../Generic_Images/close_v2.gif";
if (card.Close.src = "../../../../../Generic_Images/close_v2.gif"){
alert("I see it");

//card.Close.src =
"../../../../../Generic_Images/close_over_v2.gif";
}
//else{card.Close.src =
"../../../../../Generic_Images/close_v2.gif";}
}
else {
changeClose = "";
simpleClose = "";
document.Close = "";
}
}

function newCardWindow(){

cardHolder=window.open("", "card",
"resizable=no,width=250,height=110")

cardHolder.document.write("<html><head><title>Who is the card
holder?<\/title><\/head><body bgcolor=\"#ffffff\"
style=\"font-family:arial;\"><p>This is the person to whom the card
was officially issued during the enrollment process.<\/p><div
style=\"background-color:#00005e; bottom:0%; height:20px;
position:absolute; width:100%;\"><a onClick=\"window.close()\"
onKeyPress=\"window.close()\" id=\"CloseButtonLink\" tabindex=\"1\"
onmouseover=\"opener.rollImages()\" onmouseout=\"opener.rollImages\"
tabindex=\"1\"><div style=\"position: absolute; text-align: center;
width: 100%;\"><img src=\"..\/..\/..\/..\/..\/Generic_Images\/close_v2.gif\"
alt=\"Close Window\" name=\"Close\" id=\"Close\" width=\"66\"
height=\"20\" border=\"0\" ><\/div><\/a><\/div><\/body><\/html>")

}
down in the html the functions are called this way

<li>Color photo of the <a href="javascript:newCardWindow()">card
holder</a></li>
Jul 23 '05 #1
1 1791
bj wrote:
I have several pages that I want to allow the same kind of activity,
so my basic question is how best to structure the interaction (and I
have one related subquestion as well).

Scenario: The user clicks a hyperlink and opens a new window
in which there is a bit of explanatory text.
In a world where pop-up blocking is common that is an optimistic
statement.
This text will be different for
every link.
Hypertext.
In addition, there is an image on the page which can be
clicked to close the new window.
Your users don't know how to close a window?
(This image should rollover on mousing over and out of the image: I
haen't been able to make this work yet; help?)

I would like to pass the text,

<snip>

So you want to have all of the source HTML for each of the pop-ups on
the same page as the links? But then you want to wrap it in Javascript
so that it is completely inaccessible to users with javascript disabled
(and browsers that do not support window.open, along with the people
using pop-up blockers.).

I would say forget about the new window and put the text contents in the
HTML, and then use javascript to manipulate that HTML so it acts like a
pop-up (but doesn't risk falling fowl of pop-up blockers). Have a look
at:-

<URL:
http://www.litotes.demon.co.uk/examp...iWindow_1.html >

- the last link in the list was added for you (the rest is a response to
a question form last week). And while you are there check out the link
that disables the javascript, demonstrating how you can have your pop-up
effect and still create a system that can be used by anyone with any
browser (javascript capable or not).

Richard.
Jul 23 '05 #2

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

Similar topics

6
2361
by: Dan Webb | last post by:
Hi All, Im currently working on ways of pacakaging javascript functions/variables/objects in a similar way to the Java package statement so that scripts can be interact with each other with the...
136
9198
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...
4
5010
by: | last post by:
I have a "form field highlight" javascript that I've added to some of my ASP.NET forms using the following syntax: body.Attributes.Add("onClick", "highlight(event);");...
5
1171
by: Paul Bromley | last post by:
I have written a similar enquiry to this newsgroup, but had no responses - hence I will rephrase it with the hope that someone will answer. I am new to using Classes, but trying hard to get the...
21
1705
by: Philipp | last post by:
Hey, did anyone have a good paper about the opject orianteted concept? wishes
7
1192
by: CSharpguy | last post by:
I'm coding my first business web app in .NET 2.0 and its only a read only web app. I'm just pulling data from the database and allowing users to filter the data in the grids by using dropdowns....
37
3514
by: pochartrand | last post by:
Hello, Is there a way to manipulate or at least read the pseudo-class of an element ? I know the style attribute can be accessed and gives the CSS properties for a particular element....
3
1345
by: PJ6 | last post by:
CSS pseudoclasses are too limiting at the moment (epspecially for IE), so when I'm authoring say, a grid control, I believe there are only two possibilities - one, emit javascirpt for each cell, or...
0
7012
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...
0
7180
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,...
1
6901
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...
0
7392
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
4605
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...
0
3105
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...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
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 ...
0
307
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...

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.