Tuesday, 8 August 2006
|
| canvas.imagedata.data in Firefox 2 Beta 1 Mrc Gran 15:41:58 |
| | Hello, below is some javascript code using getIimageData() and putImageData() that doesn't seem to do what it is supposed to do (to draw a thick horizontal line inside a <canvas> element) in Firefox2 (Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1b1) Gecko/20060710 Firefox/2.0b1). I'm using the specs at http://whatwg.org/specs/web-apps/current-work/ .
The result is just a blank box. No error is displayed. I tried several variations without success.
Am I missing something or putImageData() is still just a stub? Thanks, Mg.
--
<html> <body>
<canvas id="canvas" width="200" height="100" style="border:solid"> </canvas>
</body>
<script language="JavaScript"> var mycanvas = document.getElementById('canvas').getContext("2d");
var imagedata = mycanvas.getImageData(0,0,200,100); // read from canvas
for(i=2000;i<2000+1000;i++) { //modifies 5 lines starting at the 10th line imagedata.data[i*4+0]=127;//r imagedata.data[i*4+1]=128;//g //kind of grey. imagedata.data[i*4+2]=129;//b imagedata.data[i*4+3]=130;//a
}
mycanvas.putImageData(imagedata,0,0); //write back to canvas
</script> </html>
|
| | Add comment |
|
| An old problem between layer and combobox Cylix 11:51:41 |
| | Combobox is always over all layer in a page. I remember that there is solution on a javascript tool kit.
Does anyone know the method to workaround this?
|
| | 2 answer | Add comment |
|
| Passing text to a frame in a window Guest 11:14:58 |
| | Hello Im trying to make this application that does this. The user enters text in a window clicks GO and then a new window opens with the text in a frame.
I assume I put the text in the URL. But how do I get the frame on the next window to take the text and put it in its textbox.
|
| | 2 answer | Add comment |
|
| Keypressing Not Working Dave 10:10:43 |
| | I can't figure out why my keypress script is not working. I used the following code:
document.onkeypress = KeyCheck;
function KeyCheck(e) { var KeyID = (window.event) ? event.keyCode : e.keyCode; //alert(KeyID); switch(KeyID) { case 13: title(); break; case 37: move(-1); break; case 38: toggle(1); break; case 39: move(1); break; case 40: toggle(1); break; }
}
Here's my results: ----------------------------------------------------------------------- Firefox: | Works fine. IE: | Enter key works but arrow keys don't trigger the function. Opera: | No keypresses work.
When I experienced problems, I tested the keypressing with the alert you see in the comments of the code, but aside from working in FireFox and the initial enter keypress in IE, nothing happened.
The whole page can be seen at http://thegriddle.net/rcr/ if you need to see any of the other functions or the HTML or CSS. Any ideas or suggestions would be great
|
| | 4 answer | Add comment |
|
| Delete Javascript function Guest 06:51:26 |
| | Hi
I'm creating now a site which is using heavly AJAX and what comes with it, many Javascript functions are used. However many of these functions are used only once (mainly to load new content by sending request to server and by using DOM editing site content based on the response). So keeping these functions in memory, while new content with new functions is loaded, would be just wasting of memory.
And here goes my question - is there any way to delete Javascript functions or free memory used by them? I've tried with "delete" operator but it doesn't work with functions. I thinked also about setting the function name to "null", but I'm not sure if Javascript will automaticlly free memory.
Thanks for any advices.
|
| | 2 answer | Add comment |
|
| Calling or triggering an external javascript twice Adam Smith 06:22:08 |
| | Hello,
How can I call or trigger an external javascript twice in a form? I have
<script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript" src="country_state.js"> </script>
set in between my HEAD tags.
In between the BODY tags I have The first trigger
<td><select id="countrySelect" name="compcount" onchange="populateState()"></select></td> <td> <font size="-2"><b>State</b></font></td> <td><select id="stateSelect" name="compstate"></select><script type="text/javascript">initCountry('US'); </script></td>
Which works
the second trigger calling the same external script
<td><select id="countrySelect" name="contcount" onchange="populateState()"></select></td> <td><font size="-2"><b> State</b></font></td> <td><select id="stateSelect" name="contstate"></select><script type="text/javascript">initCountry('US'); </script></td>
Which does NOT work now?
The only difference is the name of the variables, "compcount", "compstate", "contcount", "contstate", from the form input fields I am not much of a java person, but can some one say why and suggest a correction
Thanks
Adam
|
| | 4 answer | Add comment |
|
| fastest way to load and process 100 rows variable TKapler 06:22:08 |
| | I got a javasscript based aplication, which is working with data from server (php&sql, changed once per week or so). Actualy I use a xml as a data format with structure e.g. [item var1="smthng" var2="123" var3="456" var4="ABC" /] I open read the file through XMLHttpRequest and then i do smtg like
items = documentElement.getElementsByTagName("item"); for i=0 to items.lenght { var1=item[i].getAttribute("var1") ... function(var1, var2, var3, var4) }
The problem is, that it is quite slow with 100 items i'am sometimes over 5 secs total execution time on firefox and it than write an error message. The others browsers do not write this message, but they are even slower, up to 20 secs for IE The slow thing is that file access and making a variable from it.
If wonder that there may be some much faster way, as i do not need the data to be in xml, i can make any data format, i can even make something like var dump. But i do not know how to parse this dump to variable, and i do not know if it will be faster
Or are there some other fast ways how to quicker load the data?
|
| | 1 answer | Add comment |
|
| Cloning rows works -- how to alter cells? Rich_C 06:12:13 |
| | I'm able to clone a table row using this:
function insert(btn) {var cell, newRow, row, sect; if((cell = btn.parentNode) && (row = cell.parentNode) && row.cloneNode && (sect = row.parentNode) && sect.insertBefore) { newRow = row.cloneNode(true); /* If you need to alter the new row * or its contents, do it here. */
sect.insertBefore(newRow, row.nextSibling); } }
the problem is that I need to change contents of 2 cells. One cell contains an input box that should be blank in the new row, one cell contains an input box that shoule be reset to 1 in the new row. The script indicates that I can 'alter the new row', but how do I access the cell contents to make changes?
Also, the button to add rows is in the last column of the row. Is there a way to remove (or hide) it in all but the last row?
Thanks, Rich
|
| | 7 answers | Add comment |
|
| How to get the document height? Cylix 05:02:18 |
| | As I know, the document height is depend on browser and OS usering using, is there any way to get the height for that particular document height?
Thank you.
|
| | 3 answer | Add comment |
|
| settimeout needs alert() ??? Joris Lambrecht 03:32:06 |
| | Hi people,
Please take a look at the issue i talk about below. (yes i do realise such functions are publicaly available)
The page i'm using uses JSON defined array of image files with information for the title property of the img tag.
The functions i wrote below are sort of working since it needs an alert() to work the slides ???
function slideshow ( dbname ) {
var dspitem = document.getElementById("bodybox"); var fotodb = eval(dbname); var item = 0; var dblength = dbname.length -3 ;
content = "<img src=img/foto/"+fotodb.foto[item].picture+" title="+fotodb.foto[item].name+" width=100% height=540px>";
slider ();
function slider () { for (item = 0; item <= dblength; item++){ dspitem.innerHTML = "<img src=img/foto/"+fotodb.foto[item].picture+" title="+fotodb.foto[item].name+" width=100% height=540px>"; alert('temporary failure'); } setTimeout ("slider();", 500); }
}
Thank you for your advice and consideration.
Joris
|
| | 1 answer | Add comment |
|
| FAQ Topic - What is the document object model? FAQ server 03:00:01 |
| | ----------------------------------------------------------------------- FAQ Topic - What is the document object model? -----------------------------------------------------------------------
This is the collection of objects provided by each browser. Basically, any object in the window hierarchy is part of the DOM. This means that document.writeln(), for example, is not a javascript method but is, in fact, a method provided by the DOM. The DOM has been standardised by the World Wide Web Consortium (W3C); however, like all W3C standards, browser support is not yet complete. Most cross-browser coding problems come from slightly different implementations of the DOM in the differentbrowsers. W3 DOM FAQ
http://www.w3.org/DOM/faq.html
The W3C has worked on three versions of the DOM to date. The third version has not yet achieved the status of a recommendation
http://www.w3.org/DOM/
=== Postings such as this are automatically sent once a day. Their goal is to answer repeated questions, and to offer the content to the community for continuous evaluation/improvement. The complete comp.lang.javascript FAQ is at http://www.jibbering.com/faq/. The FAQ workers are a group of volunteers.
|
| | Add comment |
|
| javascript signing Guest 02:22:01 |
| | Does anyone have a good tutorial with a small sample application that covers signing and testing siging on a javascript file.
I have read the steps at http://www.mozilla.org/projects/security/components/signed-scripts.html but just don't get it... I have a small javascript app that I want to sign and test, and could use a step-by-step to do this.
Thanks
|
| | Add comment |
|
| image type button not starting javascript action Notgiven 00:49:07 |
| | This works: <input type="button" value="Add to list" onClick="addOption(param1, param2);">
But this doesn't: <img src="images/add.gif" onClick="addOption(param1, param2);">
The error I get using the img tag is, "this.form has no properties". Yet it is right beside the input tag that does work with the same OnClick= params
This doesn't work either: <input type="image" src="images/add.gif" value="Add to list" onClick="addOption(param1, param2);">
The error I get with this is that it does the javascript action then Submits the form - I do not want it to submit, just do the javascript action.
What can I do to get a graphic button that will complete the javascript action?
Thanks!
|
| | 4 answer | Add comment |
|
| target frame javascript Guest 00:05:52 |
| | I've used the following actionscript in my Flash navigational buttons to load the 5 individual contentpages in the content frame of my frameset named "content"
getURL("http://www.digitalecartoons.nl/mail.htm", "content");
This works ok.
In case someone types www.digitalecartoons.nl/mail.htm, I didn't want just the mail.htm page to be displayed. Without the navigational frame I mean. I solved this with the following javascript in each of the 5 pages, so that instead the homepage is loaded. Meaning the index.htm frameset.
<SCRIPT TYPE="text/javascript"> <!-- if (window == top) { top.location.replace("index.htm"); } //--> </SCRIPT>
This also works ok.
But now I get an email from somebody saying that when she clicks on any flash button, instead of the page being loaded into the "content" frame of the index frameset, the homepage is reloaded. As if in her case the javascript doesn't recognize the "content" part in the geturl. Thinking just the mail.htm is being accessed. Or as of the Flash button doesn't use the "content" part.
I haven't heard any complaints like this, but what could be wrong in her case? She both tried Internet Explorer and Firefox and uses the latest flash player and sun java.
|
| | Add comment |
|
| Passing info from one page to another - tricky problem Edwin 00:04:58 |
| | I've been Googling & can't find a consistent cross-browser (IE & Firefox) answer to this...
I need to pass some data from inside an iframe, to the parent page
I've got the parent page PAGE1.HTM which contains <div ID="mydata"></div> : <iframe src="page2.htm"></iframe>
And, inside PAGE2.HTM I will set mydata to a hard string. But in page2.htm do I do
var parent.document.mydata.innerHTML = "my data here'
or
var window.parent.document.all.mydata.innerHTML = "my data here"
or something else...??? to be cross-browser compatible (IE and Firefox mainly).
Thanks!
|
| | 1 answer | Add comment |
|
| second version Guest 00:04:46 |
| | I thing in this way the code is much better and short. function detectDoctype(){ var re=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi; var res=false; /********************************************* Just check for internet explorer. **********************************************/ if(typeof document.namespaces != "undefined") res=document.all[0].nodeType==8 ? re.test(document.all[0].nodeValue) : false; else res=document.doctype != null ? re.test(document.doctype.publicId) : false; if(res){ res=new Object(); res['xhtml']=RegExp.$1; res['version']=RegExp.$2; res['importance']=RegExp.$3; return res; }else{ return null; } } var myversionInfo=detectDoctype(); if(myversionInfo != null){ alert(myversionInfo.xhtml); alert(myversionInfo.version); alert(myversionInfo.importance); } else{ alert("There is no DOCTYPE in the code!"); } gonaumov@gmail.com написа:> Hi mr Michaels.> Only for fun i wrote this code. I tried it under Mozilla Firefox,> Opera 9.0 and> Internet Explorer 6.0. If there is a doctype in the document the> function detectDoctype() will return> object with 3 properties - xhtml - XHTML ot HTML , version - numer of> version and importance - stict, transitional etc. If there is no> DOCTYPE it will return null.> Best Regards.> /******************************> Version info "object"> ******************************/> function versionInfo()> {> this.xhtml="";> this.version="";> this.importance="";> }> function detectDoctype(){> var re=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;> var myversionInfo=new versionInfo();> /*********************************************> Just check for internet explorer.> **********************************************/> if(typeof document.namespaces != "undefined"){> if(document.all[0].nodeType==8)> re.exec(document.all[0].nodeValue);> else> return null;> }else{> if(document.doctype != null)> re.exec(document.doctype.publicId);> else> return null;> }> myversionInfo.xhtml=RegExp.$1;> myversionInfo.version=RegExp.$2;> myversionInfo.importance=RegExp.$3;> return myversionInfo;> }> var myversionInfo=detectDoctype();> if(myversionInfo != null){> alert(myversionInfo.xhtml);> alert(myversionInfo.version);> alert(myversionInfo.importance);> }> else{> alert("There is no DOCTYPE in the code!");> }>
Jim Michaels написа:> > I can't get any "universal" code working that tries to detect whether the> > document it's in is xhtml or html.> > I found this, which tells me I have a hill to climb with no equipment.> > http://javascript.about.com/library/bliebug.htm> > I was going to use the document.doctype property if I could, but apparently> > that isn't available unless I use strict. (just tried it with Strict, still> > doesn't do anything).> > here's what I've got. anybody got ideas that work or some pointers? I> > don't have any money for books right now, and I wouldn't know which of 100's> > of JS books to pick from.> > I am using IE6, but I want this to be cross-browser.> > <body>> > <script language="JavaScript" type="text/javascript">> > //document.getElementsByTagName('!DOCTYPE') generates an "object", but what> > type? element? if so, why won't element properties work?> > document.write(document.doctype); //prints nothing> > document.write(document.getElementsByTagName('html').getAttribute("xmlns"));> > //prints nothing> > document.write(document.getElementsByTagName('!DOCTYPE').hasAttribute("-//W3C//DTD> > XHTML 1.0 Transitional//EN")); //prints nothing> > //if (document.getElementsByName('!DOCTYPE') != null ||> > document.getElementsByName('html').getAttribute('xmlns') != null) {> > // document.write(document.getElementsByName('html').innerHTML);> > //}> > </script>> > I'm really frustrated. I lack info.> >
|
| | 10 answers | Add comment |
Monday, 7 August 2006
|
| DOCTYPE detector Jim Michaels 23:56:52 |
| | I can't get any "universal" code working that tries to detect whether the document it's in is xhtml or html. I found this, which tells me I have a hill to climb with no equipment. http://javascript.about.com/library/bliebug.htm
I was going to use the document.doctype property if I could, but apparently that isn't available unless I use strict. (just tried it with Strict, still doesn't do anything).
here's what I've got. anybody got ideas that work or some pointers? I don't have any money for books right now, and I wouldn't know which of 100's of JS books to pick from.
I am using IE6, but I want this to be cross-browser.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head>
<body> <script language="JavaScript" type="text/javascript"> //document.getElementsByTagName('!DOCTYPE') generates an "object", but what type? element? if so, why won't element properties work? document.write(document.doctype); //prints nothing document.write(document.getElementsByTagName('html').getAttribute("xmlns")); //prints nothing document.write(document.getElementsByTagName('!DOCTYPE').hasAttribute("-//W3C//DTD XHTML 1.0 Transitional//EN")); //prints nothing //if (document.getElementsByName('!DOCTYPE') != null || document.getElementsByName('html').getAttribute('xmlns') != null) { // document.write(document.getElementsByName('html').innerHTML); //} </script>
</body> </html>
I'm really frustrated. I lack info.
Jim Michaels
|
| | 13 answers | Add comment |
|
| Delete all Cookies? Guest 23:45:50 |
| | Is there any code out there for deleting all of the cookies for the current domain? I want to set up a kind of "logout" button that will remove/erase anything the user has done with cookies for the current site.
Thanks.
|
| | 1 answer | Add comment |
|
| TWO POPUP windows displaying? Kirkham99 21:20:09 |
| | Hi,
I am designing a website where if they select a MENU option it opens a New webpage called Results.htm AND that page has an ONLOAD to display a POPUP window that display a PDF document in that window.
I have setup the PDF to use Acrobats Link tool to link/when clicked to a webpage (called TRAGET.HTM as pdf CANT specify TARGET='_BLANK' etc. So the Target.htm also has another POPUP to display "another" small popup.
The 2nd POPUP appears OK BUT the problem is the first popup goes BLANK and displays in the URL section the URL of the 2nd Popup?? How can I keep the first popup to keep its contents ?
In summary I have a maths website that they select a subject and a PDF popup appears then if they select a link within that PDF it opens up another popup (via linking to another page with onload etc). The page should still display both POPUPS ...
Any help would be most appreciated...Martin
|
| | Add comment |
|
| Get stage of SWF Andrew Poulos 19:51:21 |
| | Is there a way to use javascript to get the normal stage/display size, in pixels, from the header of a compressed and uncompressed Flash SWF?
Andrew Poulos
|
| | 1 answer | Add comment |
|
| Is OBJECT or EMBED displaying SWF Andrew Poulos 19:41:23 |
| | With "normal" SWF HTML there's an EMBED tag nested within an OBJECT tag. How can I check which tag is actually displaying the SWF? I'm using CSS on them and the style on the OBJECT affects the EMBED tag so I'm going to use some code to correct it but I can't tell which tag is responsible for the display.
Andrew Poulos
|
| | 1 answer | Add comment |
|
| newbie - how do I dynamically add a field value to a select box(and remove it)? Notgiven 19:35:40 |
| | I want the user to be able to enter some text (a date actually) and click a button. The button would cause the field value to be added to a static list of dates.
I also need to be able to delete from that list as well. So I guess a list box would be the element of choice.
I would then process those dates using an array in php.
Any ideas or links on how to do this?
Many thanks.
|
| | 8 answers | Add comment |
|
| image gallery - it should be easier than this Richard 19:30:37 |
| | All I want to do is to read a list of the image files in my folder and display them on a page. That way I don't have to re-write the page, I can just upload extra images.
I don't need fancy bells or whistles or slide shows or sliders or anything.
The smallest google search I come up with offers a million pages, most of them bells and whistle types and I can't find the wood for the trees.
Can anybody help please?
Richard --
|
| | 11 answers | Add comment |
|
| addchild error in IE Brian D 17:34:05 |
| | I am trying to use AddChild in IE. The script is on a document loaded into an iframe. This works in Firefox but not IE. I receive "Invalid argument" on "objSelect.appendChild(optGroup)"
What gives?!
Thank Brian
form.html <html> <head> </head> <body> <form name="form1"> <table bgcolor="#cccccc" width="100%" cellpadding="3" cellspacing="1" border="0"> <tr bgcolor="#ffffff"> <td width="150" align="left" valign="top"><b>Item Cross Reference:</b><br>(if any)</td> <td align="left" valign="top"> <select name="itemcross" id="itemcross" size="5" STYLE="width: 400px" multiple> <option value="">Select One...</option> </select> </td> </tr> </table> </form> <iframe src="optgroup.html" name="ifrm" id="ifrm" width="100%" height="200" scrolling="yes">Sorry, your browser doesn't support iframes.</iframe> </body> </html>
optgroup.html <html> <head> <script language="JavaScript" type="text/javascript"> function create_optgroup(){ objSelect=window.parent.document.getElementById('itemcross') optGroup = document.createElement('optgroup') optGroup.label = "New Group"
objOption=document.createElement("option") objOption.innerHTML = "Sample1" objOption.value = "sample1"
objSelect.appendChild(optGroup) optGroup.appendChild(objOption) } </script> </head> <body>
<input type="button" value="test" onclick="create_optgroup();"> </form>
</body> </html>
|
| | Add comment |
|
| altering display of textarea Libsfan01 17:09:37 |
| | hi all is possible to change the look of textareas in firefox and it so that they DONT display the vertical scroll bar when there is more content in them than currently visible in the visible amount of rows.
kind regards
marc
|
| | 1 answer | Add comment |
|