Friday, 11 August 2006
|
| Hello World with YUI Library - asyncRequest Guest 21:54:35 |
| | Hi, here I have a very simple 'hello world' example that makes use of Yahoo! User Interface Library. I have a problem with my response string coming back as '[object, Object]'. I managed to check that everything else works.
The requested 'SayHello.html' file only contains the string "hello, world".
Here is my code:
<html> <head> <title>Hello World with YUI</title> <script src="yahoo.js"></script> <script src="connection.js"></script> <script language="JavaScript" type="text/javascript"> var handleSuccess = function(o){ if(o.responseText !== undefined){ document.getElementById('span_result').innerHTML = o.responseText; } }
var handleFailure = function(o){ document.getElementById('span_result').innerHTML = 'ERROR: ' + o.responseText; }
var callback = { success:handleSuccess, failure: handleFailure }; </script> </head> <body> <!-- Clicking this link initiates the asyncronous request --> <a href="javascript:YAHOO.util.Connect.asyncRequest('GET', 'SayHello.html', callback);">Say Hello</a><br> <!-- used to display the results of the asyncronous request --> <span id="span_result"></span> </body> </html>
|
| | 3 answer | Add comment |
|
| loading iframe dynamically Maya 21:54:23 |
| | hello,
how do you load an iframe dynamically? I don't mean url inside iframe, but iframe itself..
thank you..
|
| | 5 answers | Add comment |
|
| dynamic form validation / multiple forms Guest 21:54:08 |
| | Good evening all,
I'm a relatively new to javascript, but I've been working with ColdFusion and PHP for years so I'm not necessarily ignorant, just stuck and frustrated. Using ColdFusion I'm using an include to pull in form elements (text fields, checkboxes, etc...) multiple times on a single page.
The included page does not have a form tag of it's own, but the root page has uniquely named forms for validation. Imagine it like this:
<form name="form1"> <cfinclude tempalte="formtemplate"> </form>
<form name="form2"> <cfinclude tempalte="formtemplate"> </form>
I've got a simple check-one-box-and-check-em-all script INSIDE the included template. I want to reference very specifically the form name, and only check the boxes inside that form, not the others. Unfortunately, I'm not syntax savvy and my attempts to use:
<form name="form1"> <input type="checkbox" id="chkAllNorth" onClick="chkAll('chkAllNorth','northChk',this.form)"> </form>
does nothing. I can remove the this.form from the function entirely, but it checks ALL the specified boxes with that ID in ALL the forms on the page. Any help is appreciated. Here is the script:
function chkAll(thisBox,group,thisForm){ var inputs = document.thisForm.getElementsByTagName("input");
if(document.thisForm.getElementById(thisBox).checked == true){ for (i=0;i<inputs.length;i++){ if(inputs[i].id == group){ inputs[i].checked = 1; } } }else{ for (i=0;i<inputs.length;i++){ if(inputs[i].id == group){ inputs[i].checked = 0; } } } return true; }
|
| | 4 answer | Add comment |
|
| Copy content in browser Hack12 21:39:21 |
| | Hi, is there a program that will let me copy the javascript content that is in a browser. I need to save content locally so I can view it when offline. The way it shows up is in a new window in IE. The content itself is playing in flash which I am able to save via cache but I can't download the menu's etc to navigate which would be extremely useful to have. Thx
|
| | 1 answer | Add comment |
|
| Having problems with innerHTML Guest 21:17:22 |
| | Hello. I have an html page that contains javascript where when a button is clicked, a div's innnerHTML is modified based on a text box's value. If I modify the text box's value again and click the button again, the div section won't update. Below is my code. Please look at the function submitMe(). Inside the for loop, the file's path is dynamic, based on the value inside the text box. The first time this function is called everything works. On subsequent times that the function is called, the file path doesn't change based on the text box value. I would like to note that the code is not a real application at the moment, I am just trying out somethings, so some of whats going on might not make since. If you can understand the code, and see possible improvements, please let me know. Thanks.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta name="generator" content="HTML Tidy, see www.w3.org"> <title>Audio</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
function playMe(file, position) { Player.settings.requestMediaAccessRights("read");
if ( (file % 2) == 0 ) { var plRet; plRet = Player.mediaCollection.getByAlbum("Vapor Trails");
if (plRet.count > 0) { var secondItem = plRet.item(1); Player.URL = secondItem.sourceURL; Player.controls.currentPosition=position; Player.controls.play(); }
else { alert("Unable to obtain media collection"); } }
else { var plRet; plRet = Player.mediaCollection.getByAlbum("Remasters (Disc 2)");
if (plRet.count > 0) { var secondItem = plRet.item(1); Player.URL = secondItem.sourceURL; Player.controls.currentPosition=position; Player.controls.play(); }
else { alert("Unable to obtain media collection"); } } }
function submitMe() { document.all.result_section.innerHTML = "";
var htmlStr = "<div id='result_section'>"; htmlStr += "<OBJECT id=Player classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 "; htmlStr += "height='300' width='300'>"; htmlStr += "<PARAM NAME='autoStart' VALUE='true'></OBJECT><BR><BR>"; htmlStr += "<table id='table1' border=1>"; htmlStr += "<tr>"; htmlStr += "<th>Score<\/th>"; htmlStr += "<th>PAT File<\/th>"; htmlStr += "<th>Time Offset<\/th>"; htmlStr += "<\/tr>";
alert(htmlStr);
var scoreCount = 34.0;
for (i = 0; i < 5; i++) { htmlStr += "<tr>"; htmlStr += "<td>" + (scoreCount + i) + "<\/td>"; htmlStr += "<td><a href='javascript layMe(" + i + "," + scoreCount; htmlStr += ");'>C:\\program files\\nexidia\\media\\" + document.form1.search_term.value; htmlStr += "\\file1.mp3</a></td>"; htmlStr += "<td>00:04:30</td>"; htmlStr += "</tr>"; scoreCount += 5.0; }
htmlStr += "</table></div>";
document.all.result_section.innerHTML=htmlStr; }
</script> </head>
<body> <div id="search_section"> <form method="get" name="form1">Please enter search term: <input name="search_term" value=""><br> <br> <input type="button" name="Submit" value="Submit" onclick="submitMe()"> </form> </div>
<div id="result_section"></div> </body>
</html>
|
| | Add comment |
|
| Dynamic script of some sort needed for mp3 linking Guest 20:48:56 |
| | I have a couple of questions for the HTML/CSS/CGI/YouNameIt masters out there...
(oh, and sorry fi this is in the wrong are of Groups - I'm not exactly sure what scripting method this requires)
(1) If I have a mp3 file (let's call it Andrew.mp3), and I want to host it on a website I own, how could I implement some script that, as soon as I drag the mp3 file into a specific folder, would parse "Andrew.mp3" as a string, tear off the ".mp3" part of the new string, (thereby taking "Andrew" as a string) and put this string up on my website? This new text "Andrew" would also need to be hyperlinked to the Andrew.mp3 file mentioned earlier. Basically, this would be a very dynamic process.
In addition, it'd be nice if the next time I drag *any* .mp3 file in this scripted folder, it did the exact same thing, but it kept up the older link (to Andrew.mp3) as well. Let's call this new file "SecondFile.mp3".
So it'd look like this -
SecondFile (note: this would be hyperlinked to SecondFile.mp3) Andrew (note: this would be hyperlinked to Andrew.mp3)
(2) Is there some cool script that recognizes if you have the Adobe reader, and if you don't, it redirects/suggests you visit the Adobe website?
Thanks!
~Andrew
|
| | 2 answer | Add comment |
|
| I can't figure this out! Please tell me what's wrong! _Raven 20:13:09 |
| | Okay, I am playing with submitting forms with Ajax. I am trying to adapt this script to my forms: http://www.captain.at/howto-ajax-form-post-get.php
I have included my code at the bottom of this post.
Basically, this will work correctly if I remove all non-form related tags from the form => eg span, div, but I want to format the form all pretty like so??? Right now, it only collects 2 parts of the form fields => sites[] & banner_id All of the other fields are skipped or dropped or something, they are not getting passed to PHP at all. I cannot for the life of me figure out what is wrong, and was hoping someone has had simlar experience and can help me out. I did modify the original javascript to also include hidden fields, but no other modifications.
WARNING: the css is not firefox compliant! (I havent had chance yet as I was just testing)
the contents of get.php are:
<?php print_r($_GET); ?>
and my complete HTML with css and javascript:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Banners</title> <script language="JavaScript" type="text/javascript"> <!-- var http_request = false; function makeRequest(url, parameters) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type //http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('GET', url + parameters, true); http_request.send(null); }
function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { //alert(http_request.responseText); result = http_request.responseText; document.getElementById('myspan').innerHTML = result; } else { alert('There was a problem with the request.'); } } }
function get(obj) { var getstr = "?"; for (i=0; i<obj.childNodes.length; i++) { if (obj.childNodes[i].tagName == "INPUT") { if (obj.childNodes[i].type == "text") { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } //added hidden field if (obj.childNodes[i].type == "hidden") { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } //end mod if (obj.childNodes[i].type == "checkbox") { if (obj.childNodes[i].checked) { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } else { getstr += obj.childNodes[i].name + "=&"; } } if (obj.childNodes[i].type == "radio") { if (obj.childNodes[i].checked) { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } } } if (obj.childNodes[i].tagName == "SELECT") { var sel = obj.childNodes[i]; getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&"; }
} makeRequest('get.php', getstr); } --> </script> <style> <!-- .bannerBox{ width : 776px; height : auto; position : relative; border : 1px solid #000000; }
.bannerImage{ width : 776px; height : auto; border : 1px solid #FF0000; }
.bannerOptions{ width : 200px; height : auto; border : 1px solid #000000; float : left; clear : none; margin : 6px 0px 6px 0px; }
.bannerForm{ width : 574px; border : 1px solid #000000; float : right; clear : both; margin : 6px 6px 6px 6px; }
.bannerSubmit{ width : 776px; height : auto; border : 1px solid #0000FF;
}
.cBox{ display : inline; width : 30px; font-family : tahoma; font-size : 9pt; background-color : inherit; padding-left : 4px; } .cText{ width : 80px; font-family : tahoma; font-size : 9pt; padding-left : 2px; } .cInput{ width : 488px; font-family : tahoma; font-size : 9pt; color : #0000FF; padding-left : 2px; } .msgBox{ font-weight : bold; font-family : tahoma; color : #0000FF; text-decoration : overline underline; font-size : 18pt; margin : 10px; } .cReqd{ border-width : 1px 1px 1px 1px; border-style : solid; border-color : #FF0000; } .upper{ text-transform : uppercase; } .disChk{ display : inline; background-color : inherit; width : 13px; height : 13px; }
.cReqdText{ color : #FFFFFF; text-transform : uppercase; text-align : center; text-decoration : underline; margin : 2px 2px 2px 2px; padding : 2px 2px 2px 2px; width : 100%; background-color : #FF0000; } .siteDisplay{ display : inline; width : 100%; background-color : #f2f2f2; font-weight : bold; text-align : center; font-family : tahoma; font-size : 10pt; } .displayBox{ border : 1px solid #000000; margin : 1px 1px 1px 1px; } .sites{
padding : 1px 2px 1px 2px; } .buffer{ margin : 6px 0px 6px 0px; } .cHelp{ /*display : none;*/ margin-left : 80px; font-family : tahoma; font-size : 8pt; line-height : 8pt; width : 488px; background-color : #f2f2f2; padding : 0px 0px 3px 0px; } #cBoxes{ margin : 0px; text-align : center; width : 100%; color : #FF0000; } #cShow{ float : right; clear : none; cursor : pointer; font-family : tahoma; font-size : 8pt; line-height : 8pt; color : #0000FF; } #cHide{ float : right; clear : none; cursor : pointer; font-family : tahoma; font-size : 8pt; line-height : 8pt; color : #0000FF; } caption.messages{ font-weight : bold; } #navDiv{ text-align : center; margin : 6px 0px 10px 0px; background-color : inherit; width : 100%; height : 16px; vertical-align : middle; } #navDiv span{ margin : 6px 6px 6px 6px; } #navDiv span a{ text-decoration : none; color : #000000; } #navDiv span a:hover{ text-decoration : underline overline; color : #0000FF; } fieldset.stats{ width : 760px; } .r{ border-right : 1px solid #000000; border-bottom : 1px solid #000000; } .l{ border-bottom : 1px solid #000000; } .t{ border-right : 1px solid #000000; } --> </style> </head> <body> <div class="bannerBox"> <a name="#banner115"></a> <fieldset style="width:760px;"> <legend>Banner #115</legend> <div class="bannerImage"><a href="" style="" target="_blank"><img src="http://www.banners.com/banners/03.gif" alt="" onMouseover="window.status=''; return true;" onMouseout="window.status=''; return true;" border="0" style="" /></a></div> <span class="bannerOptions"> <span class="siteDisplay">Display on:</span> <span class="cHelp" id="cBoxes">Banner to display on these sites:<br></span> <form action="javascript:get(document.getElementById('myform2'));" name="myform2" id="myform2"> <input type="hidden" name="banner_id" value="115"> <input type="checkbox" class="disChk" name="site[]" value="1"><span class="cBox">D01</span> <input type="checkbox" class="disChk" name="site[]" value="2"><span class="cBox">D02</span> <input type="checkbox" class="disChk" name="site[]" value="3"><span class="cBox">D03</span> <input type="checkbox" class="disChk" name="site[]" value="4"><span class="cBox">D04</span> <input type="checkbox" class="disChk" name="site[]" value="5"><span class="cBox">D05</span> <input type="checkbox" class="disChk" name="site[]" value="6"><span class="cBox">D06</span> <input type="checkbox" class="disChk" name="site[]" value="7"><span class="cBox">D07</span> <input type="checkbox" class="disChk" name="site[]" value="8"><span class="cBox">D08</span> <input type="checkbox" class="disChk" name="site[]" value="9"><span class="cBox">D09</span> <input type="checkbox" class="disChk" name="site[]" value="10"><span class="cBox">D10</span> <input type="checkbox" class="disChk" name="site[]" value="11"><span class="cBox">D11</span> <input type="checkbox" class="disChk" name="site[]" value="12"><span class="cBox">D12</span> <input type="checkbox" class="disChk" name="site[]" value="13"><span class="cBox">D13</span> <input type="checkbox" class="disChk" name="site[]" value="14"><span class="cBox">D14</span> </span> <span class="bannerForm"> <span class="siteDisplay">Banner Properties:</span> <span class="cHelp"><span class="cReqdText">Fields in red are mandatory!<br></span></span> <label for="banner" class="cText">Banner:</label><input type="text" name="banner" class="cInput cReqd" value="http://www.banners.com/banners/03.gif"><br> <span class="cHelp">Banner: The full path to the banner image.<br></span> <label for="linking_code" class="cText">Link Code:</label><input type="text" name="linking_code" class="cInput cReqd" value=""><br> <span class="cHelp">Link Code: The linking code.<br></span> <label for="mouseover" class="cText">Mouseover:</label><input type="text" name="mouseover" class="cInput cReqd" value=""><br> <span class="cHelp">Mouseover: The text displayed in status bar when banner is moused over.<br></span> <label for="alt" class="cText">Alt:</label><input type="text" name="alt" class="cInput cReqd" value=""><br> <span class="cHelp">Alt: The text displayed to user when image is unavailable.<br></span> <label for="sorter" class="cText">Sorting ID:</label><input type="text" name="sorter" class="cInput cReqd upper" value="S" maxlength="1"><br> <span class="cHelp">Sorting ID: The alphabet letter that is used to determine where banner is displayed in list.<br></span> <label for="border" class="cText">Border:</label><input type="text" name="border" class="cInput" value="0" value="0"><br> <span class="cHelp">Border: width in pixels for image border. Defaults to 0.<br></span> <label for="link_style" class="cText">Link Style:</label><input type="text" name="link_style" class="cInput" value=""><br> <span class="cHelp">Link Style: Inline css passed to <a> tag. Syntax: [:space:]style=""<br></span> <label for="banner_style" class="cText">Banner Style:</label><input type="text" name="banner_style" class="cInput" value=""><br> <span class="cHelp">Banner Style: Inline css passed to <img> tag. Syntax: [:space:]style=""<br></span> <label for="description" class="cText">Description:</label><input type="text" name="description" class="cInput" value=""><br> <span class="cHelp">Description: Description of banner.<br></span> <label for="keywords" class="cText">Keywords:</label><input type="text" name="keywords" class="cInput" value=""><br> <span class="cHelp">Keywords: Keywords for banner, used for searching.<br></span> </span> <span class="bannerSubmit"><input type="submit" name="bannerUpdate" value="Update Banner" onclick="javascript:get('myform2');"></span> </form> </fieldset> </div> Server-Response:<br> <span name="myspan" id="myspan"></span> </body> </html>
|
| | 4 answer | Add comment |
|
| restrictions on the content of floating panel ? Erik Verhagen 19:17:30 |
| | Hello, I am using floating panels (ajax), like the beautifull ones you find in the Dojo toolkit. Is there any restriction on the content of the panel ? I am able to load a standart web page in it (like it is on www.protopage.com). But why can't I load a sophisticated (ajax, like wikipedia) web page in it ? idealy I would like to be able to launch several little floating-panel-browsers in one web page body. is this possible ? regards,
Erik
|
| | Add comment |
|
| re-route events in IE (or rich text woes) Jceddy 19:07:16 |
| | Well, there is something here I'm working on, and I have a problem that has several possible solutions...none of which I can figure out how to implement.
Basically, I am creating a rich text editing element, using design mode in IE, that validates/cleans up the contents of anything that is pasted into it.
The element that has design mode on is the body of a page nested within an IFRAME in the main page.
The problem is this: If the user pastes something into the document using CTRL-V, I am able to detect the paste and go ahead to validate the new contents of the document. If, however, the user pastes something into the document by DRAGGING it from another source, there doesn't seem to be an event that I can capture.
The ondrag/drop events seem to be disabled in IE in designMode, and when something is being dragged, no mouseover/down/up events fire. The document body doesn't seem to have an onpaste event that I can capture, though I have seen this event on other elements.
So...possible solutions?
Is there any way to disallow drag/drop pasting in an element in IE with design mode turned on?
I could put an "invisible" div over the IFRAME, to control access to the IFRAME, but then I need a way to re-route the appropriate events (onmousedown, onmouseup, etc.) to the IFRAME from the invisible div...anyone know of a way to do that?
I could manually move the cursor, selection, etc., around in the IFRAME...IF I could figure out a way to move the cursor/change the selection in an element with designMode on, based on the mouse position...but I can't seem to figure out a way to do that, either.
I'm going to try embedding a DIV that takes up the whole window in the IFRAME, and have THAT be the rich text cotnainer, because maybe it will be easier to capture the onpaste events...we'll see.
|
| | 2 answer | Add comment |
|
| Navigare nel fileSystem con JAVASCRIPT Lorologiodoro 18:04:42 |
| | ciao a tutti, ho la necessita in un pagina jsp di navigare sul disco locale quindi di poter reperire l'elenco delle cartelle e dei files contenuti in una cartella ... partendo dalla root ...
qualcuno di voi sa come fare!?
Grazie
|
| | 2 answer | Add comment |
|
| Dynamic forms, show/hide layers Chris_huh 17:39:52 |
| | I have a script which means that when a certain radio button is clicked more form options that relate to that radio button show up.
The form is layered in way that means that if you answer one question a DIV appears that contains another question which itself when ansered brings up another DIV.
The only problem i have is that i need to have the first DIV to remain visible after the second question is answered, at the moment it disappears, which makes sense since the hideAll function does that. I guess what i need to do is have another line in the onClick property of the second question radio button, but i don't know whether i need to write a new function or not.
I hope you understand what i mean, and i hope someone has an idea how to fix it.
The script i am using is shown below:
<script type="text/javascript"> <!--
// function switchDiv() // this function takes the id of a div // and calls the other functions required // to show that div // function switchDiv(div_id) { var style_sheet = getStyleObject(div_id); if (style_sheet) { hideAll(); changeObjectVisibility(div_id,"visible"); } else { alert("sorry, this only works in browsers that do Dynamic HTML"); } }
// function hideAll() // hides a bunch of divs // function hideAll() { changeObjectVisibility("residential","hidden"); changeObjectVisibility("commercial","hidden"); changeObjectVisibility("house","hidden"); }
// function getStyleObject(string) -> returns style object // given a string containing the id of an object // the function returns the stylesheet of that object // or false if it can't find a stylesheet. Handles // cross-browser compatibility issues. // function getStyleObject(objectId) { // checkW3C DOM, then MSIE 4, then NN 4. // if(document.getElementById && document.getElementById(objectId)) { return document.getElementById(objectId).style; } else if (document.all && document.all(objectId)) { return document.all(objectId).style; } else if (document.layers && document.layers[objectId]) { return document.layers[objectId]; } else { return false; } }
function changeObjectVisibility(objectId, newVisibility) { // first get a reference to the cross-browser style object // and make sure the object exists var styleObject = getStyleObject(objectId); if(styleObject) { styleObject.visibility = newVisibility; return true; } else { // we couldn't find the object, so we can't change its visibility return false; } } // --> </script>
thanks
|
| | Add comment |
|
| Endgame RTS on Google Maps (BETA) Jshanman 17:28:45 |
| | I invite the members and viewers of this group to try my Real Time Strategy Multiplayer game created using the Google Maps API.
This has not been announced until now and I am looking for developer feedback before I announce the public BETA test to other internet sources.
Endgame on Google Maps: http://www.endeavorpub.com/endgame
To create a test game... Go to: http://www.endeavorpub.com/endgame/browse.php Signup for a real account (stored) or a guest account (removed after a few hours) Create a Game Either wait for players or just start the game by yourself (you will only be able to attack neutral countries if by yourself)
I am very interested in any/all feedback. So far, I've only tested this application in IE6 and Firefox 1.5.
Thanks! - JS http://www.endeavorpub.com
|
| | 3 answer | Add comment |
|
| ie node attributes problem Chotiwallah 16:16:27 |
| | i'm having a problem with ie's node object. this is a code snippet:
$element = document.createElement('button'); $element.setAttribute('onclick', 'some_function();');
the button element is created all right, and the onclick attributeis there when you examine the node. the problem is: some_function() is not executed when you click the button. the whole thing works in firefox.
any ideas to solve this?
micha
|
| | 4 answer | Add comment |
|
| File download: save or cancel? Roger Withnell 14:46:02 |
| | On downloading a file from a database, I need to update the database on the status of the downloaded file (eg when it was downloaded and by whom).
How can I tell if the user has clicked save or cancel on the download dialogue?
Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com
|
| | 1 answer | Add comment |
|
| trigger click on button when Enter Key is pressed Guest 13:29:39 |
| | Hi, This is driving me crazy. In the following code, with e==68 (ASCII code for 'D'), the button is given the focus and the click is trigered However, if I change to e==13 (ASCII code for Return carriage) then it never works, and instead the first button in my page is clicked. It's lilke the Return carriage key is assigned to that one button and there's nothing that can override this behaviour !!!
My code :
function CheckKey(e){
if( !e ) { //if the browser did not pass the event information to the //function, we will have to obtain it from the event register if( window.event ) { //Internet Explorer e = window.event; } else { //total failure, we have no way of referencing the event return; } } if( typeof( e.keyCode ) == 'number' ) { //DOM e = e.keyCode; } else if( typeof( e.which ) == 'number' ) { //NS 4 compatible e = e.which; } else if( typeof( e.charCode ) == 'number' ) { //also NS 6+, Mozilla 0.9+ e = e.charCode; } else { //total failure, we have no way of obtaining the key code return; }
if (e == 68){
getEl('ctl00_cpBody_btnSearchPub').focus(); getEl('ctl00_cpBody_btnSearchPub').click(); } }
Can you help ?
Thanks
|
| | 1 answer | Add comment |
|
| Why won't the radio button get checked? Ray 13:21:34 |
| | Hi there,
I have a table, each row of which contains 5 radiobuttons that the user uses to specify a rating. From radio button to my object, no problem there. However when I want to populate the radiobuttons with the correct value, somehow they are not checked. Any idea why?
var ratingTd = document.createElement('TD'); for(var c = 1; c <= 5; c++) { var ratingText = "<input type=\"radio\" name=\"eventRating" + index + "\" value=\"" + c +"\">"; var newCb = document.createElement(ratingText); if(("" + c) == item.rating) { newCb.checked = true; } var span = document.createElement('span'); span.appendChild(newCb); span.appendChild(document.createTextNode(c)); ratingTd.appendChild(span); } row.appendChild(ratingTd);
I've stepped through the debugger to see that yes, the code newCb.checked=true gets called according to the correct rating. But in the rendered screen none of the buttons are ever checked. Why would that be, I wonder?
Thanks Ray
|
| | 1 answer | Add comment |
|
| JavaScript documentation Guest 12:59:52 |
| | Can anyone tell me if there is a JavaScript manual online somewhere, similar to the PHP manual at php.net? I am also wondering if the JavaScript language specification is online. Is it online for the various different versions?
|
| | 2 answer | Add comment |
|
| send post variables roN 10:11:10 |
| | Hi, how can I send post variables from out of a php script to another script? I need to send some post var to a third party script, but would like to insert our own php script between the html-form and the third-party script...
Thank you!
Ron
|
| | 2 answer | Add comment |
|
| Cross Domain Scriptng with FRiednly Domains Jacob JKW 04:26:54 |
| | Having read the CLJ FAQ and having done extensive Googling, I do understand that in in general cross-domain iframe scripting is not permitted. One issue I have not seen directly addressed, however, is scripting across different but still "friendly" domains.
Essentially I'd like to send a signal from the child to the parent in any form at all. I would think that there might exist a way to set some variable or object property that could both be read by the parent and written to by the child (or vice versa).
Am I just totally wrong?
Thanks, Jacob.
|
| | Add comment |
|
| Why won't window.onload fire after window.open? - or - Safari and IE, how I loathe thee Guest 04:05:39 |
| | I'm working on part of a larger project, and in trying to debug one aspect, I've got a small test file to work with.
The code is practically identical (all important aspects match word for word) to the larger project, which works fine in IE and Firefox so far, but my little test fails in IE, and I cannot figure out why.
http://geekforhire.org/tests/window_open_onload.html
It's supposed to open the window, change the background color, and add a word to the body.
In IE, it never makes it to the callback function, as if the onload isn't firing. Is there some quirk of events I'm unaware of?
It should be noted that the code also fails in Safari, but I expected that as the original project fails in Safari as well (this all started in an attempt to find a working solution for Safari as well).
So basically, how can I make it fire the onload for all 3 browsers?
|
| | 2 answer | Add comment |
|
| incrementing variables in javascript Mantrid 02:47:11 |
| | Hello I have the following code, where clicking yh1r is supposed to move h1 10px down and update the value of yh1 by 20 each time its clicked. what the code actually does is NOT move h1 and instead of incrementing yh1 from 0 to 20 to 40 etc it doubles it and appends it to the original value each time eg 0 to 20 to 4020 to 804020 to 160804020
<div id='h1' style='position:absolute; top:<?php echo $yh1/2;?>px; <?php $h1; ?></div>
<input name="yh1" id="yh1" type="text" class="BodyText" value="<?php echo $yh1; ?>" size="1"> <input name="yh1r" id="yh1r" type='button' class="BodyText" onClick="yh1move(10)" value='>'>
function yh1move(amount) { var yh1val=document.form2.yh1.value; yh1val += amount; h1.style.top =yh1val+'px'; document.form2.yh1.value = yh1val*2; }
but when I give yh1val a numerical value to start, as below it works
var yh1val = 0; function yh2move(amount) { yh1val += amount; h2.style.top =yh1val+'px'; document.form2.yh2.value = yh1val*2; }
can anyone see what the problem is? Ian
|
| | 8 answers | Add comment |
|
| XMLHttpRequest connection is causing IE to lock up Coolvirus 02:10:41 |
| | Kind of long but please bear with me.
I built a website that shows pricing information, as close to real-time as possible. It consists of a main page and the main page pops up a child window (onLoad event on the main window).
The child window uses an XMLHttpRequest object to retrieve the updated pricing info. It sends a request to a server side script. This script looks for new prices and sends a response accordingly right away if there are any. If there aren't any, the server script loops for 30 seconds, constantly checking for new prices and after 30 seconds of not finding any new content, it sends a response accordingly. If at any time during this 30 second loop the script finds new content, it breaks out of the loop and send the appropriate response. Once the client receives the response, it displays the new info if any and sends the request to the server again to look for new prices. The server script is written in PHP.
The problem I'm experiencing (only happens with IE) takes place when the user closes the child window. When they reload the main window or re-login in order to open the child window with the pricing info again, that instance of IE takes FOREVER to load the main website and sometimes it locks up.
I've done some research and found that IE allows 2 HTTP connections at a time. I also read somewhere that IE has a bug that keeps connections open when they should be closed, allowing for the possibility of most, if not all, connections to be tied up.
I think I'm having that problem because after the user kills the child window and reloads the main window (to pop up the child window again), the main window loads its contents, one at a time, very slowly, and only after the child window receives the response from the server. So after the user closes the child window for whatever reason and then reloads the main window in an attempt to popup the child window again, this is what I think it's happening:
1. After user reloads main window, it attempts to load its contents VERY SLOWLY, probably because there are hanging HTTP connections that were not terminated by the browser when the child window was first closed.
2. Child window is popped up. It sends a request to server script to fetch new info. The Connection header is set to "close" in order to terminate that connection once the transaction is finished (this was an attempt to make sure there were no connections "hanging").
3. Server script loops for a few seconds until updates come in. Once they do, it sends a response to the client.
4. Client receives response. Connection "should" be terminated (don't know how to determine this for sure). At this point, the main window loads a little more but not completely.
5. Client sends request again and ... (Go back to step 3).
The only way to solve this problem is to close all windows (main website and child window) and re-login from scratch. Sometimes the problem is so bad that ALL instances of IE need to be killed.
I added a function to be called when the child window is closed (onBeforeUnload event) to abort the XMLHttpRequest (only when status is not 0 or 4, otherwise unpredictable results might occur) but this did not help.
Does anyone have any idea as to why the website is so eternally slow to load or why does it lock up sometimes? I'm kind of new at using the XMLHttpRequest and don't know if I'm handling things correctly. Any input will be greatly appreciated.
Here's the code for the child window for illustration purposes:
<html> <head><title>Updates</title> <script src="ajax_util.js" type="text/javascript"></script> <script type="text/javascript">
var doc = 'check_updates_file.php';
// initialize XMLHttpRequest object var xmlobj=null;
function show_new_content() { // this shows new content. }
function setRequest() { loopRequest(); }
function loopRequest() { // check for existing requests if( xmlobj != null && xmlobj.readyState != 0 && xmlobj.readyState != 4 ) { xmlobj.abort(); }
xmlobj = createXMLHttpRequest(); xmlobj.onreadystatechange=stateChecker; xmlobj.open('GET',doc,true);
// this should prevent the browser from caching xmlobj.setRequestHeader("Cache-Control", "no-cache"); xmlobj.setRequestHeader("If-Modified-Since", "Wed, 31 Dec 1980 00:00:00 GMT"); xmlobj.setRequestHeader("Expires", "Wed, 31 Dec 1980 00:00:00 GMT");
// this should make sure the connection is closed after // receiving the response from the server xmlobj.setRequestHeader("Connection", "close");
xmlobj.send(null); }
function stateChecker() { var data=new Array();
if( typeof(xmlobj) != "undefined" && xmlobj != null && xmlobj.readyState == 4 ) { if( xmlobj.status == 200 ) { data=xmlobj.responseText.split('\n');
if( data[0] == "NEW CONTENT" ) { show_new_content(); } } else if( xmlobj.status != 0 ) { alert("Failed to get response: " + xmlobj.status + " - " + xmlobj.statusText); }
setRequest(); } }
function winClose() { if( typeof(xmlobj) != "undefined" && xmlobj != null && xmlobj.readyState != 0 && xmlobj.readyState != 4 ) { xmlobj.abort(); } }
</script> </head> <body onload="setRequest();" onbeforeunload="winClose();"> ... some content here ... </body> </html>
|
| | Add comment |
|
| Enabling & disabling image buttons Barq 01:44:30 |
| | I'm using image in an anchor tag as a submit button. We use document.images['img_name'].parentElement.removeAttribute('href') in a javascript function to make a image button non-clickable (not-hyperlink). How do we make it clickable again (have a hyperlink).
Thanks in advance
|
| | 1 answer | Add comment |
Thursday, 10 August 2006
|
| Aaagh. Please help me debug this simple JavaScript code. Guest 22:08:50 |
| | Here's the code which I'm saving in an HTML and opening in a Java enabled browser. It's giving me the following error:
Line: 34 Char: 1 Error: Object Expected
Many thanks in advance for any help.
Code follows: ============================ <html> <head> <script language="javascript">
function chkSelectAll(strMatch,frm) { for (var i=0; i < frm.elements.length; i++) { var form_field = frm.elements[i]; var field_name = form_field.name;
if (field_name.substring(0,strMatch.length)) == strMatch) { if (form_field.type == "checkbox") { form_field.checked = true; } } } }
</script> </head> <body>
<form name='bsForm'> <input type='checkbox' name='chkbox1' /> <input type='checkbox' name='chkbox2' /> <input type='checkbox' name='chkbox3' /> <input type='checkbox' name='chkbox4' /> <input type='checkbox' name='chkbox5' /> </form>
<a href='#' onClick='chkSelectAll("chkbox",document.bsForm);'>CLICK</a>
</body> </html>
|
| | 6 answers | Add comment |
|
| Review of new "Understanding Ajax" book. Tony Lawrence 21:58:39 |
| | Probably a lot of you here are already old hands at Ajax, but I haven't started doing this yet. Part of the reason was that I really didn't understand where Ajax would be useful to my own site, and also that my experiences with early Javascript put me off on that a bit.
"Understanding Ajax" by Joshua Eichorn helped me with both of those impediments. Complete review at http://aplawrence.com/Books/understanding_ajax.html
-- Tony Lawrence http://aplawrence.com
|
| | 1 answer | Add comment |
|