| css layer not working in Firefox or Netscape |
|
 |
Index ‹ javascript
|
- Previous
- 2
- select form variable to javascript function.Hi, i am trying to get a function to work, but i am still learning
javascript and i really need some help.
i have a select form
<select ="menu1" onChange="onMapClick(menu1.value)">
<option selected>Select Dataset</option>
<option value="massey_07">Turitea 2007</
option>
<option value="Massey_02_2003">Turitea
2003</option>
<option value="All_orthos">Turitea</
option>
<option value="albany2005">Albany 2005</option>
<option value="albany2004">Albany 2004</option>
<option value="albanycom">Albany</option>
</select>
and i want to make the value from this form into a variable and pass
it to this function as "imageSRC"
<script language="javascript">
// User clicked a new region. Parameter is name of that region.
function onMapClick(){
menu1.value = imageSRC;
document.ECWView1.DeleteAllLayers();
document.ECWView1.AddLayer("ECW", "ecwp://" + document.location.host +
"/Massey/images/Massey/" + imageSRC + ".ecw", "RasterLayer",
"freecache=TRUE");
}
</script>
i have tried lots of different things, but i firefox's firebug console
tells me that -
menu1 is not defined
onchange(change )
what am i doing wrong?
sorry, this is probably really basic.
Matt
- 5
- How to check for the officer version installed with javascriptDear all,
I would like to know how to check for the MS Access version that is
installed on someones computer via a webpage. I thought vbscript
would work, but because I cannot figure out how to run vbscript on the
clients machine I cannot work. Basically it could have a button or an
even or somekind then when this event executes the test says you have
this verison os MS Acess installed you computer: 97, 200, 2002, or
2003.
You can do this my looking into the registry or any other method you
like.
email me if you want to vbscript code.
Thanks a bunch,
Vince
email***@***.com
- 5
- Get last active element..Hi,
I have three textareas and four buttons within a form. The buttons has
often used text as value. When I press a button I whant the assigned
text to be added in whatever textareas im currently in (the one with
cursor blinking). Is this possible with Javascript?
--
Tommy Myrvoll
- 7
- javascript for converting given date to the required timezoneI have date(ex., Thu, 04 Dec 2003 10:35:19 +0500) and I know the
timezone(ex., America/Anchorage). Now I need to convert the date into
the given timezone. Is it possible to achieve this thru js api's?
Is yes, please guide me.
Thanks in advance,
Bhaskar
- 7
- 8
- Netscape DOM issue?I want to use a pop-up dialog for my intranet, but I'm missing
something that keeps me from getting along with NS's browsers right
now.
I get an error to the effect of "opener.formName has no properties"
The following JS is its own file included in caller.html and
callee.html with this syntax <SCRIPT language="JavaScript"
src="pops.js"></SCRIPT>
It works in current IE's on multiple platforms and in Apple's Safari.
Any ideas about how I might work it for NS?
Thanks,
Mark
// <pops.js>
var DEBUGGING=false;
var myTarget=null;
function popUp(argURL, argOBJ, argH, argW) {
/* Useage example from caller.html:
<FORM name="stockForm">
<INPUT name="txtA" type="text" id="txtA" value="" size="10" />
<INPUT name="btnA" type="button" id="btnA"
onClick="popUp('callee.html', this)" value="." /><BR />
</FORM>
*/
try {
// default to 300x300, otherwise use options offered
argH=(!argH || argH==0) ? 300 : argH;
argW=(!argW || argW==0) ? 300 : argW;
// establish error message in case something goes wrong
var Err = new Error();
Err.message="mcs.js popUp(" + argURL + ", " + argOBJ.name + ", " +
argH + ", " + argW + ") error:\n\nmyTarget not established or window
not opened";
// set aside the name of the object which will be receiving the
value chosen in the popUp window
// presumes usage from naming as used above txtA and btnA
myTarget=argOBJ.form.name+'.'+'txt'+argOBJ.name.substr(3,
argOBJ.name.length-3);
if (DEBUGGING) alert('myTarget='+myTarget);
// open the popUp
listWin=window.open(argURL, 'list', 'height='+argH+',
width='+argW+', left =100, top=100, location=no, menubar=no,
resizable=yes, scrollbars=yes, status=no, toolbar=no');
// complain if it didn't work
if (myTarget==null || !listWin) throw(Err);
}
catch (Err)
{ alert(Err.message); }
}
function popDown(argVAL) {
/* Useage example from callee.html:
<A href="#" onClick="popDown('AMZN')">AMZN</A>
*/
try {
// establish error message in case something goes wrong
var Err = new Error();
Err.message="mcs.js popDown("+argVAL+") error:\n\nmyTarget not set";
var evalMe="opener."+opener.myTarget+".value="+"'"+argVAL+"'";
if (DEBUGGING) alert('evalMe='+evalMe);
eval(evalMe);
// if myTarget != val then complain
if (eval("opener."+opener.myTarget+".value!="+"'"+argVAL+"'"))
throw(Err);
else window.close();
}
catch (Err)
{ alert(Err.message); }
}
// </pops.js>
- 10
- toggle questionI wondered if anyone would give me code- I think it would be easy, but
I'm a complete newbie. What I want to do is to show many tables in a
brief truncated format and then for each table offer the user the
ability to toggle so they can see the full content of each table
individually. The code I got from the net below works fine for *one*
table but when I try to add a 2nd table it does not work. How can I
apply this toggle individually to each table?
<html>
<script>
function toggle(e) {
if (e.style.display == "none") {
e.style.display = "";
}
else {
e.style.display = "none";
}
}
</script>
<table border=2px><tr><td>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<br>
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee<br>
<div id=aa style="display:none"> </a>
cccccccccccccccccccccccccccccccccccccccccccccccc<br>
ddddddddddddddddddddddddddddddddddddddddd<br>
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee<br>
</div>
</td></tr></table>
<a href=javascript:toggle(aa)><b>see more</b></a>
<!-- If I add this table below, it does not work -->
<table border=2px><tr><td>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<br>
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee<br>
<div id=aa style="display:none"> </a>
cccccccccccccccccccccccccccccccccccccccccccccccc<br>
ddddddddddddddddddddddddddddddddddddddddd<br>
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee<br>
</div>
</td></tr></table>
<a href=javascript:toggle(aa)><b>see more</b></a>
</html>
- 10
- preserving html tags in a selection w/SafariI'm trying to teach myself a little javascript on the mac, and in the
course of doing so, I decided to try to create a bookmarklet to open a
selected area of text in a new window (Using Safari 1.0.1). This is
easy enough to accomplish, but I'd like to preserve the html markup
of the selected text. To my knowledge, createRange() doesn't work with
Safari, and I can't think of a way to do it. Here's what I have;
javascript:outText=getSelection();if(!outText){void(0)};if(outText){newwindow=window.open('','selectionWindow','width=800,height=600');newwindow.document.write('<body>'+outText+'</body>');newwindow.document.close()}
Is there a means of replacing getSelection() with something that will
preserve the html tags within the selection??
Thanks in advance!
- 11
- reference local frame object from framesetIn a page that's in a frame ('mainFrame') I'm creating a new object
var ft = new FTobj();
and from the frameset I'm trying to reference this object but I keep
getting 'undefined'. I've tried:
window.frames['mainFrame'].ft
window.frames['mainFrame'].window.ft
window.frames['mainFrame'].document.ft
window.frames['mainFrame'].window.document.ft
I know the object exists because it calls a function in the frameset
that later tries to call a method of the object.
I don't understand what I'm doing wrong. How can a frameset reference an
object created in a frame?
Andrew Poulos
- 11
- return contents of executed parsed urls to variablesHi all,
i am making a DOM solution for displaying contents. My
problem is that i got a includet Javascript file *.js.
Within i builded my standart functions for use of any
page i code. I want to fill an array with contents of
the page that needs to be displayed.
The problem is now, that i simply cant exec the *.php
file and catch all echoes.
Yes, your way is right...
My thoughts are now, to execute the php as simple link
but i need to have something like pipes to return the
output to the variable.
This should normally work, couse of the serversidet
impementation form php scripts.
I'm new to Javascript, so i dont know where to start
my first steps and (how to || it gives) something like
(pipes || functions that return the value of executed urls
|| catch echos of files i execute)
Does someone can help me?
Greets Lis.
- 13
- Recommend an AJAX autocomplete component. (cost $50)Just have a look at the screencast: http://capxous.com/screencast/
there is a 160kb flash demo.
:)
CAPXOUS.AutoComplete is a handy AJAX auto complete component.
Developers could build their own Area Code auto complete, Group Code
auto complete, Material Code auto complete ... with ease! It's
specially easy to use!
* The latest version is 0.9.2.
* Formerly named AutoAssist.
* Supports Pagination, Page Up, Page Down.
* Supports ASP, ColdFusion, dot NET, Java, Perl, PHP, Python, Ruby
...
* Supports Internet Explorer, FireFox, Mozilla, Camino, Konqueror,
Opera. (Safari support in progress)
- 13
- proposed new standard: JSON++http://htmatters.net/htm/1/2005/07/evaling-JSON.cfm
This is more or less in response to Mr Crockford's admonition a few
months ago, "fork if you must". Ironically, although in that usenet
post he calls what I am suggesting "brittle", his own Javascript JSON
parser is not valid JSON, but rather conforms to my proposed variation
on JSON!! With an identifier prepended to the front of the JSON block,
and function literals as values: see
http://www.crockford.com/JSON/json.js
Out of deference to Mr Crockford's outstanding original idea, I propose
this new standard be called JSON++. One of my key motivations is to
help a JSON-based technology to get more traction; XML is entrenched as
a data format so I believe adding declarative capabilities could make
JSON more valuable.
- 14
- Cross browser mouse wheel event handlerHey all:
I'm trying to write a cross-browser (IE and firefox) event handler for
the mousewheel. Basically my web app is an image viewer, so if you
scroll "down" with the wheel the next image should be displayed and if
you scroll "up" the previous image should be displayed.
So far I have:
function handleMouseWheel(e)
{
if (!e) e = window.event;
if ( e.wheelDelta <= 0 || e.detail > 0) { changeImage(1); }
else { changeImage(-1); }
}
This code works in IE and in Firefox to the desired effect. The
problem I am having is with registering the event handler.
The following works for IE:
document.onmousewheel = handleMouseWheel;
And the following works for Firefox:
window.addEventListener("DOMMouseScroll", handleMouseWheel, false);
But when I add the firefox event handler to my code, IE chokes with an
error "Object doesn't support this property or method".
What do I need to do to "hide" the firefox event handler code from IE?
-CJL
- 15
- Send a browser to a link with JavascriptHow do you send a browser to a link when a command is given? I've
tried using Java Server Pages <jsp:forward /> command but that doesn't
change the link in the address bar and some other problems arise with
it. A javascript method would work in what I'm doing but I don't know
what that command would be. Basically, when a button is pressed I want
some session data to be set and for a link to be followed.
Any ideas?
- 15
- How to force submit if values changeI have a .NET datagrid that has a column of dropdownlist controls. If the
user changes the value in the dropdown in one or more rows I will set a
flag. If the user subsequently attempts to (1) leave the page, or 2) close
the window, I want to present an Alert reminding them to first submit their
data.
Anyone know how to do this?
TIA,
Dewey
|
| Author |
Message |
jsreblev

|
Posted: 2005-11-26 6:23:15 |
Top |
javascript, css layer not working in Firefox or Netscape
Hi Javascript gurus:
I have tried several things, using several Javascript books, but can't get
this to work in Netscape (latest version) and Firefox (latest v.). It works
in MIE and Opera fine. A box (defined by a css layer) is supposed to pop
out to the right when the corresponding box on the far left is moused over.
The first function defines a layer id to the next function which pops out
the box. After debugging in Venkman, it looks like the first function
cannot define the layer id properly to the second function, which actually
slides the box (layer) to the right.
I thought that the getElementById function was supposed to work for Firefox,
but I must be using it wrong(???)
To see how it's supposed to work, view the following page in MIE or Opera:
http://www.tfn.net/~chorale/join_us.html
function makeName(layerID) {
if (document.all)
{ refname = eval("document.all." + layerID + ".style") }
else if (document.layers)
{ refname = eval("document.layers(layerID)"); }
else
{ refname = document.getElementById("layerID"); }
// { refname = layerID }
// { refname = eval("document." + layerID) }
// { refname = eval("document." + layerID) }
// { refname = layerID; }
return refname;
}
function slide () {
if ((parseInt(layername.left) < xgoal) ||
(parseInt(layername.top) < ygoal))
{ layername.left = parseInt(layername.left) + xhop;
layername.top = parseInt(layername.top) + yhop;
// window.setTimeout("slide()", delay)
}
else if ((parseInt(layername.left) == xgoal) ||
(parseInt(layername.top) == ygoal))
{ layername.left = parseInt(layername.left) - xhop;
layername.top = parseInt(layername.top) - yhop;
// window.setTimeout("slide()", delay)
}
}
This is a portion of the HTML code that calls the box (in this case, the
"sponsors" css class), and assigns it a layer name, which is then passed to
the slide function, which moves the box to the right based on the x & y
coordinates. The box is defined by a css <div class=> statement as
'sponsors'.:
layername=makeName('sponsors'); yhop=0; ygoal=150; xhop=165; xgoal=165;
slide()";
Thanks for any help you can give.
--
Rebecca Levings
Lively Health Products
850-443-4641
email***@***.com
http://www.lively.myarbonne.com
https://www.juiceplus.com/athlete/+rl21248
|
| |
|
| |
 |
Danny

|
Posted: 2005-11-26 15:13:00 |
Top |
javascript >> css layer not working in Firefox or Netscape
You are leaving out .style as part of the object assignment in the
.layers and .getElementById lines for "refname":
if (document.all)
{ refname = eval("document.all." + layerID + ".style") }
else if (document.layers)
here ^
{ refname = eval("document.layers(layerID)"); }
here^
else
{ refname = document.getElementById("layerID"); }
and here^
chances are IE is using the .all part, since is in met in the IF and
skipping the rest, thus it works, Opera does .all object too, so,
Geckos do .all too but limited.
Danny
|
| |
|
| |
 |
David Dorward

|
Posted: 2005-11-26 15:25:00 |
Top |
javascript >> css layer not working in Firefox or Netscape
jsreblev wrote:
> if (document.all)
Needed exclusively for Internet Explorer 4. Other versions of Internet
Explorer support it. Some other browsers support it, but, AFAIK they all
return false if you test for it (on the principle that if you are smart
enough to test for it, your smart enough to use the standard DOM).
> else if (document.layers)
Needed for, and supported only by, Netscape 4.x.
> { layername.left = parseInt(layername.left) + xhop;
http://www.mozilla.org/docs/web-developer/upgrade_2.html#dom
Not going near the style property of the element, and failing to set units
(which are required for non-zero lengths).
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
|
| |
|
| |
 |
RobG

|
Posted: 2005-11-26 17:58:00 |
Top |
javascript >> css layer not working in Firefox or Netscape
jsreblev wrote:
[...]
> function makeName(layerID) {
>
> if (document.all)
> { refname = eval("document.all." + layerID + ".style") }
What Daivd said, plus the use of eval here is totally redundant:
refname = document.all.layerID.style;
There is also no need to make refname global (it's not needed at all).
Test getElementById first, it will suit 99% of browsers:
if (document.getElementById) {
return document.getElementById(layerID).style;
} else if (document.all)
return document.all[layerID].style;
} else if (document.layers){
return document.layers(layerID);
}
return null;
Untested, based on your code.
[...]
--
Rob
|
| |
|
| |
 |
Lee

|
Posted: 2005-11-26 21:53:00 |
Top |
javascript >> css layer not working in Firefox or Netscape
RobG said:
>
>jsreblev wrote:
>[...]
>> function makeName(layerID) {
>>
>> if (document.all)
>> { refname = eval("document.all." + layerID + ".style") }
>
>What Daivd said, plus the use of eval here is totally redundant:
>
> refname = document.all.layerID.style;
>
>There is also no need to make refname global (it's not needed at all).
>Test getElementById first, it will suit 99% of browsers:
>
> if (document.getElementById) {
> return document.getElementById(layerID).style;
> } else if (document.all)
> return document.all[layerID].style;
> } else if (document.layers){
> return document.layers(layerID);
return document.layers[layerID];
Square brackets would be required in this rare case.
> }
> return null;
>
>
>Untested, based on your code.
>
>[...]
>
|
| |
|
| |
 |
| |
 |
Index ‹ javascript |
- Next
- 1
- NETSCAPE fails to run Body onLoad, WHY ?!?!In IE, this runs fine, but in Netscape, it doesn't error, but just
doesn't run. WHY?!?!
(in the Page Code Behind)
BODY1.Attributes.Add("onLoad", "DisplayData();")
(in the HTML of the Page)
function DisplayData(){
PanelDescription.style.display = 'none';
PanelBuildingName.style.display = 'none';
PanelOperatorName.style.display = 'none';
PanelManagementName.style.display = 'none';
...(yada yada yada)
Thanks
BTHOMAS71CHEVY-at-EXCITE-dot-COM
- 2
- appendChild not working in IE6I have the following code:
##############
var nHead=(document.getElementsByTagName)?document.getElementsByTagName("head").item(0):document.head;
var nStyle=document.createElement("style");
// nStyle.type="text/css";
nStyle.setAttribute("type","text/css");
nHead.appendChild(nStyle);
var cssText=document.createTextNode(
'\r\t.class1 { font-family: Verdana, sans-serif; font-size:1; color:#ffff00; font-weight: bold;} '+
'\r\t.class2 { font-family: Verdana, sans-serif; font-size:1; color:#00ffff; font-weight: bold;} '+
'\r\t.class3 { font-family:Arial,sans-serif;font-size:3;color:#00ff00;font-weight: bold;} '+
'\r\t.class4 { font-family:Arial,sans-serif;font-size:3;color:#0000ff;font-weight: bold;} '+
'\r\t.class5 { font-family:Arial,sans-serif;font-size:3;color:#ff0000;font-weight: bold;} \r'
);
nStyle.appendChild(cssText);
##############
this last nStyle.appendChild(cssText); returns the following error in IE6:
Error: Unexpected call to method or property access.
Code: 0
in FF this seems to work
Can anybody point out the problem?
- 3
- When is a function not a function?I've got a collection of functions that accept a function or object
(paired with a method name) as a callback.
For the longest time I have relied on this test.
(typeof cb == 'function')
This should work as well, but I am not sure how well it degrades in
older browsers. I think there are issues with functions created in
another context (eg frame) as well.
(cb instanceof Function)
Then I came across this.
(!!fn && typeof fn != "string" && !fn.nodeName && fn.constructor !=
Array && /function/i.test( fn + "" ))
I'm sure it is wrong as it is from jQuery, but it makes me wonder if
there are bugs in older browsers that will mislead my test.
As an aside, I was looking at the jQuery source as some browser
sniffer I was arguing with on a blog cited it as part of an "everybody
is doing it" argument. I had glanced at it previously and dismissed
it based on its resemblance to Prototype. Upon closer inspection, it
makes Prototype look inspired. Suffice to say that anybody who
recommends it hasn't read the code. It's a horror show.
- 4
- 5
- innerHTMLHi for everyone. First of all i'm trying to explain waht i want to do.
I need to insert some code (for example the beggining of a table)
before the code inside of a div, and some other code (for exaple the
end of a table) after the code inside of a div. Here is an example:
Actual code:
<body>
<div id="idDIV">
<table>
<tr>
<td>Some text</td>
</tr>
</table>
</div>
</body>
I want to make the code above like this:
<body>
<div id="idDIV">
<table>
<tr>
<td>
<table>
<tr>
<td>Some text</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
I'm trying to do this with this code:
var code = '<table><tr><td>'+document.all.idDIV.innerHTML+'</td></tr></table>';
document.all.idDIV.innerHTML = "";
document.all.idDIV.innerHTML = code;
This code work if inside the Div there isn't a table, if inside the
div exists a table an error ocur: "Untermiated string"
Anybody know hoy can i fix this?
Thanks,
Alejandro
- 6
- image handling in jsHi newsgroup,
I'm just wondering if it is possible to display an image purely from
javascript? For example, it is possible to receive a text string and
document.write() the current document to dynamically recreate the HTML.
Is there a way to create an image by receiving an image binary string
and somehow use js to display it?
This is just out of my curiosity. It might not even be practical.
M
- 7
- 8
- Javascript read web directoryI need to make a javascript read a web directory from a remote site (ie
"http://remotesite.com/images")
(The remote die does not have an index.htm and does have directory
listing enabled)
I have seen many samples but they all use frames or iframes, all I want
is a method that you can say
<body onload="readremotedir('http://remotesite.com/images');">
and the method would get the directory listings and populate an array
var Pic = new Array()
Sorry in advance for something that may be easy, I know little about
Javascript
Are there any samples that dont use frames/iframes
Thnanks, Ed,
- 9
- Mozilla Drop-down menus head-scratchI am doing drop-down menus for a site I'm developing (not my idea,
neadless to say.) I have a nice robust Javascript that handles it, and
it actually WORKS, works across browsers even! How unexpected!
However, I have one TINY problem. In netscape, ON OCCASION, the
drop-down menus will show up halfway down the page. Reloading fixes
this. Resizing the windows fixes this. (It's asising, I think,
because of the Mozilla reansparent-picture-image-location hack for
determing position of the original menu on the page.) And it doesnt'
appear consistently.
This is what I THINK is going on- when I double-click to refresh
instead of single, the document re-loads, but some part of the layout
beign generated by the first-click isn't properly cleared. (this bug
onyl shows up when the page reloads funny, but it's often enough I want
it not to happen, because it's MASSIVELY ugly.) Resizing the window
causes it to recalculate the layout positions of those transparent
gifs, and so it fixes itself.
The script I have it really good. (It was someone else's, which I've
mads some additiosn to.) I'd prefer NOT to gut and rebuild if I can.
Especially not for a netscape-only problem.
Is there a way to... 'poke' the document resize event when the page is
finished loading and cause it to recalculate this? I think (provided
it doesn't cause a page redraw) that would solve my problem, and it's
simple enough I don't mind it as a concession to the browser.
Or, has anyone else encountered this and have an alternate solution?
Am I wrong on the cause? Etc.
Technical: the dropdowns are absolutely-positioned DIV's with a z-index
of 20 whose position is determined by the location of a transparent
image before the to-level navigation option they're attached to.
-Derik
- 10
- Using variables in [document.VARIABLE.VARIABLE.checked], etc...I would like to use variables in...
for(q = 0; q < i; q++) {
if(document.varArray1[q].varArray2[q].checked == TRUE) {
alert("YES");
}
else {
alert("NO");
}
}
What's the proper syntax?
--
[ Sugapablo ]
[ http://www.sugapablo.com <--music ]
[ http://www.sugapablo.net <--personal ]
[ email***@***.com <--jabber IM ]
- 11
- Clear A FormGood Day -
I have a form with 3 radio buttons that, when one is clicked, one of three
tables is displayed, (determined by the selection), each of which has 5
radio buttons. Clicking one of the first three radio buttons selects one
part of a location/time data pair, and clicking one of the 5 secondary
buttons from one of the three tables displayed selects the second part of
the location/time data pair. This works as expected.
However, I find that a user can select button #1 (location), and then select
a time from one of the five options displayed in the appropriate table, BUT
the user can then select another location (from one of the first three radio
buttons), which then opens the appropriate table for that selection, and if
the user does not make a selection from the new display, what I am left with
is a location/time data pair which don't match.
Is there a way to programmatically clear the form of data on the second
selection of one of the first three radio buttons, such as an onClick or
other event handler?
Any help or suggestions will be greatly appreciated, as this is the final
step in a long process.
Thanks in advance.
Mike Hagstrom
- 12
- window.opener HELP!!I have a normal window cotaining a form (named form1). The form has a text
input called imageURL. There is a button that, when clicked, opens a new
window that contains three frames (left, right and bottom.) In the right
frame is another form (named form2) with a hidden input (selected). When
form2 is submitted, I want the value of selected to be passed back to the
imageURL on form1 and then close.
The code I have tried is as follows:
(From my frame...)
<SCRIPT language="JavaScript">
function passValues()
{
// pass variable back to parent window
window.opener.document.form1.imageURL.value =
document.form2.selected.value;
}
top.window.close();
</SCRIPT>
It closes just fine, but imageURL on form1 never changes.
Anyone with ideas on how to make this work is encouraged to offer their
help!!
- 13
- In IE, forcing focus on window makes dropdown selects inoperableWe are developing a web page that shows large graphics. To provide
more screen space for the graphics, we allow the user to popup a
window that places itself over the top part of the browser. This popup
contains a control panel that tells the main window what to display.
Because we don't want to require that the user continually ALT-TAB to
go between the main window and the popup (all user controls are on the
popup) in the control panel popup, we have the following:
in the function called by onLoad in the popup, the following line is
executed:
window.onblur= keepFocus;
later in the .js file we have:
function keepFocus() {
self.focus();
}
The problem is that when the user tries to use a dropdown select
control the list drops down and immediately rolls back up, making it
inoperable.
This doesn't happen in the Netscape/Mozilla family or browsers. Nor
does IE report an error.
Any ideas would be appreciated.
Dave
- 14
- need help with code. still learninganyone at all able to help???????????????
"OzThor" <email***@***.com> wrote in message
news:email***@***.com...
OK, i'm only just starting to understand javascript.... and trying to get
the following code to work....
I have a program that generates a webpage, which is were i got the code
from. trouble is that the original code uses frams that i do not want so
have cut it back to the following...
It now gives the opening screen, but when you click on "Check" it dose not
update the score etc...
could anyone help here, pointing out why and how to fix???
i'd like to learn as i get this working....
thanks....
the code......
a copy is attached..
<html>
<head>
<title>
Mix & Match
</title>
<script language="javascript" type="text/javascript">
x = new Array();
var CorrectIndicator = ':-)';
var IncorrectIndicator = 'X';
var YourScoreIs = 'Your score is '; //'Your score is: ';
var CorrectResponse = 'Correct! Well done.';
var IncorrectResponse = 'Sorry! Try again. Incorrect matches have been
removed.';
var TotalUnfixedLeftItems = 0;
var TotCorrectChoices = 0;
var Penalties = 0;
var ExerciseTitle = 'EMC Mix & Match'; //'Test exercise';
var ExerciseSubtitle = 'Matching exercise'; //'Multiple-choice';
var Instructions = 'Match the items on the right with the items on the
left.'; //'';
var DefaultResponse = '[strDefaultResponse]';
var ReadingURL = '';
var NavBar='<br>';
var TitleCode = '<tr><td align="center" valign="middle" bgcolor="#ffffff">';
TitleCode += '<font size="+1" face="Geneva,Arial" color="#000033">' +
ExerciseTitle + '</font><br />';
TitleCode += '<font size="-1" face="Geneva,Arial" color="#000033">' +
ExerciseSubtitle + '<br />';
TitleCode += '</font></td></tr>';
var TableOpener = '<center><form name="QForm">';
TableOpener += '<table border="0">';
var IRow = '<tr><td valign="top" bgcolor="#bbbbee">';
IRow += '<font face="Geneva,Arial"
color="#000000">[strLeftItem] </font></td>';
IRow += '<td valign="top" bgcolor="#bbbbee">';
IRow += '<font face="Geneva,Arial"
color="#000000">[strRightItem]</font></td>';
IRow += '<td valign="top" bgcolor="#bbbbee"><font face="Geneva,Arial"
color="#000000">';
IRow += ' [Mark]';
IRow += '</font></td></tr>';
var CheckButton = '<tr><td valign="top" align="center" bgcolor="#bbbbee"
colspan="3"><br /><input type="button" value="Check"
OnClick="CheckAnswers()"></input></td></tr>';
TableCloser = '</table></form></center>';
var DropDownList = '';
var Exercise = '';
function Shuffle(InArray){
Temp = new Array();
var Len = InArray.length;
var j = Len;
for (var i=0; i<Len; i++){
Temp[i] = InArray[i];
}
for (i=0; i<Len; i++){
Num = Math.floor(j * Math.random());
InArray[i] = Temp[Num];
for (var k=Num; k < j; k++) {
Temp[k] = Temp[k+1];
}
j--;
}
return InArray;
}
function WriteFeedback(Feedback) {
//Build the output string
var OutString = '';
// OutString += '<html>';
// OutString += '<body background="" bgcolor="#ffffff" text="#000000"
link="#0000ff" vlink="#0000cc">';
OutString += '<center><table border="0" cellpadding="5" cellspacing="1"
width="85%">';
OutString += NavBar;
if (Feedback.length>0){
OutString += '<tr><td bgcolor="#bbbbee" align="center">';
OutString += '<font face="Geneva,Arial" size="-1" color="#000000">';
OutString += Feedback;
OutString += '</font></td></tr>'
}
OutString += '</table></center>';
// OutString += '</body></html>';
//Write it to the frame
document.write(OutString);
}
function BuildSelector(){
DropDownList = '<select name="sel[INum]">';
DropDownList += '<option value="??? ">??? </option>';
for (var i=0; i<RItems.length; i++){
DropDownList += '<option value="' + EscapeDoubleQuotes(RItems[i][0]) +
'">' + RItems[i][0] + '</option>';
}
DropDownList += '</select>';
}
function StartUp(){
CorrectIndicator = '<nobr>' + CorrectIndicator + '</nobr>';
IncorrectIndicator = '<nobr>' + IncorrectIndicator + '</nobr>';
//Write the top frame
WriteFeedback(Instructions);
//Create the right-item/distractor array, and shuffle it
var DuplicateItem = false;
for (var i=0; i<I.length; i++){
//If it's not fixed
if (I[i][2] < 1){
if (I[i][0].length > 0){
TotalUnfixedLeftItems++;
}
DuplicateItem = false;
//and it's not already in the array
for (var j=0; j<RItems.length; j++){
if (I[i][1] == RItems[j][0]){
DuplicateItem = true;
RItems[j][1][RItems[j][1].length] = i;
}
}
//add it to the array
if (DuplicateItem == false){
RItems[RItems.length] = new Array();
RItems[RItems.length-1][0] = I[i][1];
RItems[RItems.length-1][1] = new Array();
RItems[RItems.length-1][1][0] = i;
}
}
}
RItems = Shuffle(RItems);
//Now tell the I array items which of the selector items matches to it
for (i=0; i<RItems.length; i++){
for (j=0; j<RItems[i][1].length; j++){
I[RItems[i][1][j]][3] = i;
}
}
//Now use the RItems array to build the drop-down list selector
BuildSelector();
//Create arrays
CreateStatusArrays();
//Build and show the exercise
BuildExercise();
DisplayExercise(Exercise);
}
function BuildExercise(){
var TempRow = '';
Exercise = '';
for (var i=0; i<I.length; i++){
//if there's a left item -- ie it's not a distractor
if (I[i][0].length > 0){
TempRow = IRow;
TempRow = ReplaceStuff('[strLeftItem]', I[i][0], TempRow);
//if not fixed and not yet answered correctly
if ((I[i][2] < 1)&&(Status[i][0] < 1)){
TempRow = ReplaceStuff('[strRightItem]', DropDownList, TempRow);
}
else{
TempRow = ReplaceStuff('[strRightItem]', I[i][1], TempRow);
}
//if it's not fixed, and it's been attempted, mark it appropriately
if ((I[i][2] < 1)&&(Status[i][1] > 0)){
if (Status[i][0] < 1){
TempRow = ReplaceStuff('[Mark]', IncorrectIndicator, TempRow);
}
else{
TempRow = ReplaceStuff('[Mark]', CorrectIndicator, TempRow);
}
}
else{
TempRow = ReplaceStuff('[Mark]', '', TempRow);
}
TempRow = ReplaceStuff('[INum]', i, TempRow);
Exercise += TempRow;
}
}
//Add the check button
Exercise += CheckButton;
//Make it into a table
Exercise = TableOpener + Exercise + TableCloser;
}
I = new Array();
I[0] = new Array();
I[0][0] = 'Elvis';
I[0][1] = 'love me tender';
I[0][2] = 0;
I[1] = new Array();
I[1][0] = 'queen';
I[1][1] = 'help';
I[1][2] = 0;
I[2] = new Array();
I[2][0] = 'beatles';
I[2][1] = 'yesterday';
I[2][2] = 0;
I[3] = new Array();
I[3][0] = 'acdc';
I[3][1] = 'ego';
I[3][2] = 0;
I[4] = new Array();
I[4][0] = 'and one more';
I[4][1] = 'any song';
I[4][2] = 0;
Status = new Array();
RItems = new Array();
function CreateStatusArrays(){
for (var x=0; x<I.length; x++){
Status[x] = new Array();
Status[x][0] = 0; // Item not matched correctly yet
Status[x][1] = 0; //Tries at this item so far
}
}
function ReplaceStuff(Token, Replacement, InString){
var i = InString.indexOf(Token);
var FirstBit = '';
var LastBit = '';
while (i>-1){
FirstBit = InString.substring(0, i);
LastBit = InString.substring(i + Token.length, InString.length);
InString = FirstBit + Replacement + LastBit;
i = InString.indexOf(Token);
}
return InString;
}
function EscapeDoubleQuotes(InString){
var Result = '';
for (var i=0; i<InString.length; i++){
if (InString.charAt(i) == '"'){
Result += '"';
}
else{
Result += InString.charAt(i);
}
}
return Result;
}
function DisplayExercise(StuffToDisplay){
//Build the output string
var OutString = '';
// OutString += '<html>';
// OutString += '<body background="" bgcolor="#ffffff" text="#000000"
link="#0000ff" vlink="#0000cc">';
OutString += '<center><table border="0" cellpadding="5" cellspacing="1"
width="85%">';
OutString += TitleCode;
OutString += '<tr><td bgcolor="#bbbbee" align="center">';
OutString += '<font face="Geneva,Arial" size="-1">';
OutString += StuffToDisplay;
OutString += '</font></td></tr>';
OutString += NavBar;
OutString += '</table></center>';
// OutString += '</body></html>';
//Write it to the frame
document.write(OutString);
}
function GetAnswer(INum){
var Result = -1;
var s = eval('document.QForm.sel' + INum);
if (s != null){
Result = s.selectedIndex - 1;
}
return Result;
}
function CheckAnswers(){
var AllDone = true;
TotCorrectChoices = 0;
//for each item not fixed or a distractor
for (var i=0; i<I.length; i++){
if ((I[i][2] < 1)&&(I[i][0].length > 0)){
//if it hasn't been answered correctly yet
if (Status[i][0] < 1){
//Add one to the number of tries for this item
Status[i][1]++;
//Get the answer
if (GetAnswer(i) == I[i][3]){
//The answer is correct, so set the status flag
Status[i][0] = 1;
}
//else the answer is wrong, so remember that
else{
AllDone = false;
}
}
//If it's correct, count it
if (Status[i][0] == 1){
TotCorrectChoices++;
}
}
}
//Calculate the score
var Score =
Math.floor(((TotCorrectChoices-Penalties)/TotalUnfixedLeftItems)*100);
var Feedback = '';
//Build the feedback
if (AllDone == true){
Feedback = CorrectResponse + '<br />' + YourScoreIs + Score + '%.';
}
else{
Feedback = IncorrectResponse + '<br />' + YourScoreIs + Score + '%.';
//Penalty for incorrect check
Penalties++;
}
//Show the feedback and rebuild the exercise
WriteFeedback(Feedback);
BuildExercise();
DisplayExercise(Exercise);
}
</script>
</head>
<body onload="StartUp()">
// <script>
// StartUp()
// </script>
</body>
</html>
- 15
- script to open a new window and populate it with a single item from a listHere is what I want to do with javascript.
On a page with text place a javascript link that:
1) When a user clicks the link (onClick) a new browser window opens
(the easy part) NewWindow =
window.open("windowpage.html","newWin","width=100,height=100")
2) Once the window is open I want to pull a specific item from a list
of items (array) and populate the open window with only that item. The
list of items would be in a separate .js file. Call it "definitions.js"
3) The (example) list of items (on definitions.js) has a list of terms
and definitions:
Example List:
TermArray = new Array();
DefinitionArray = new Array();
TermArray[0] = "Stop Sign"
DefinitionArray[0] = "Stop Sign: A red sign with the word STOP.";
TermArray[1] = "Yield Sign"
DefinitionArray[0] = "Yield Sign: A yellow sign with the word YIELD.";
TermArray[2] = "Go Sign"
DefinitionArray[0] = "Go Sign: A green sign with the word GO.";
TermArray[3] = "Right Turn Sign"
DefinitionArray[0] = "Right Turn Sign: A white sign with an arrow
pointing RIGHT.";
4) The new browser window can then be closed by clicking a
"javascript:window.parent.close()" link.
So basically I'd like to pass a variable, but I'm not exactly sure
how structure the script on the referring page/link.
Can anyone send me a link to a resource that would describe doing this
or can show me the script?
Thank you,
TPK
|
|
|