473,811 Members | 3,152 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.image s){
changeClose = new Image;
simpleClose = new Image;
changeClose.src = "../../../../../Generic_Images/close_over_v2.g if";
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.g if";
}
//else{card.Close .src =
"../../../../../Generic_Images/close_v2.gif";}
}
else {
changeClose = "";
simpleClose = "";
document.Close = "";
}
}

function newCardWindow() {

cardHolder=wind ow.open("", "card",
"resizable=no,w idth=250,height =110")

cardHolder.docu ment.write("<ht ml><head><title >Who is the card
holder?<\/title><\/head><body bgcolor=\"#ffff ff\"
style=\"font-family:arial;\" ><p>This is the person to whom the card
was officially issued during the enrollment process.<\/p><div
style=\"backgro und-color:#00005e; bottom:0%; height:20px;
position:absolu te; width:100%;\">< a onClick=\"windo w.close()\"
onKeyPress=\"wi ndow.close()\" id=\"CloseButto nLink\" tabindex=\"1\"
onmouseover=\"o pener.rollImage s()\" onmouseout=\"op ener.rollImages \"
tabindex=\"1\"> <div style=\"positio n: 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="javascrip t:newCardWindow ()">card
holder</a></li>
Jul 23 '05 #1
1 1810
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
2384
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 minimum risk of clashing (due to function/variable name clashes). Do any of you do this already and/or are there any techniques you've come across? Im aware that ECMAScript 2 has this facility and have seen several
136
9469
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
4
5058
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);"); body.Attributes.Add("onKeyUp", "highlight(event);"); Some of my forms have a great many text box controls that I want to highlight.. I would much rather that ASP.NET do the work of looping through all text boxes and applying these two attributes.
5
1185
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 basics at the present time, and seem to be winning. Presently I am developing a Usercontrol for use in my application. To keep it simple, let me give as an example - I have 3 command buttons in the User Control. Each of these will have separate...
21
1744
by: Philipp | last post by:
Hey, did anyone have a good paper about the opject orianteted concept? wishes
7
1216
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. I've been reading and seen how you can drag and drop the controls and bind them that way, though I'm used to coding using a business layer and datalayer. So my question is since this is only a view only site, would it make more sense to use the new...
37
3594
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. However, I can't seem to access the "hover" properties. example :
3
1357
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 two, emit javascript to wire up events to each cell client side. I've read a lot about the benefits of using the second approach because it "saves bandwidth"... but really. That's trivial unless you have a large number of rows, in which case you...
0
9730
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
9605
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,...
0
10651
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10392
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10403
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,...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
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
5555
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...
2
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.