I have a page that is useing javascript to poll a backend script every 2 seconds then append the new data to the

http://pastebin.com/m2ac0deab
thats the script Byron

2 secs?

sorry lol it was on my laptop :p
oh sorry there should be a if (field == "") { } inside notblank
there ammended it
any ideas

hi

is there a javascript eviv to die() in php?

try {} catch () {}

option value='1'Here The city Name /select

can I get somehow the "Here The City Name" with getelementbyId()
or something ?
I am able to get the value (1) but not the Here The city name

getelementbyId().value

that gives me the '1'

it will as thats the value

that's not my goal?

oh

I want to get the "Here The City Name"

put that as the value=""

I can't, I need the value code for mysql query after :p
but need the content as javascript host test before hehe

I can't do obj.style.float ?

hey, i have one textfield and one button, i wrote down to textfield and press button but id like to just press enter, how i could do it?

I think I resolved the problem
var selectList = document.getElementById("city");
alert(selectList[document.getElementById("city").value - 1].text);
seems to work

oh wicked, learn something everyday
i didnt know you could do that

anyway thanks for the "help"

Is there a way I can clear the page and use document.write() as if it was never used?

$("body").html("");

thanks

oh lol wrong channel

er
Not for me?

that;ll only work if u use jquery :P

So, is there a way I can do it

document.getElementsByTagName('body').innerHTML = "";

I'm trying to write a calender window for selecting dates
ok
Will that work on other tags like table?

this, not me

Why do many sites reference their .css and .js files with "?number"? Like core.js?52. Is this to force caches to reload when they make a change?
Sounds like a really dirty hack.

yes
actually, it doesn't force caches to reload, it makes them load for the first time, repeatedly

Not if the number is the same.
Until the Web master changes it.
…. right?

oh, if the number is fixed, then it's just a version number

"Just"?
Isn't this why we have HTTP and headers and shit?
To determine the right time to reload?

I thought you were referring to the technique of generating a number clientside
in which the client wants to be sure of getting the latest version, so each request it makes has a different number
which, if the content hasn't changed, means that caches end up with copies of the same content differing only in URL
bwhich, if the content hasn't changed, means that caches end up with copies of the same content differing only in URL/b
but if it's a server-assigned number that identifies a particular version, then they're all different, and the same URL always refers to the same content, allowing it to be marked fresh for years
you could call the files core.52.js or whatever, it wouldn't matter to caches

I have problems with a menu. When I click on a menu-item the text somewhere else in the menu gets selects. Any way around this?

cancel the click event

is there a different way?

use browser-specific selection-prevention properties

what if I have different eventhandlers on different layers for the same event?

are there ECMAscript implementations that file I/O?

JS with file I/O?
That would be stupid

Opera doesn't support className?

yes, all the ones that TiddlyWiki will work on

hi I'm creating some DHTML, and one of the bits creates img nodes… displays fine on firefox, but on IE it doesn't show the image. Instead I have to right click and go to 'show picture'. How do I force IE to show it?

I'm sure it does

anyone any ideas?

it's not stupid. It's stupid if you want to have a browser supporting that. ECMAscript can be used for other stuff too (actionscript)

so how do I get IE to render images properly that I've set/created with javascript?

yeah, it does thanks, though

hmph

hi guys
where i mistake?
echo "img src=\"$dir_smiles$smile\" alt=\"$smile\" OnClick=\"Smiles(\"$smile\");\"\n";

"img src=\"$dir_smiles$smile\" alt=\"$smile\" OnClick=\"Smiles(\"$smile\"

:O
echo "a"

"a"

lol
error javascript on Smiles( -
:/

ffs IE is retarded

couldnt agree more

I'm creating some images via javascript, in a table…
some of them get rendered, some don't
the ones that don't, I have to right click on and 'show picture'

blame MS for that

wtf!!?

IRCFrEAK, are you using "new Image()" ?

IE has stubbornly tried to avoid following the W3C standard
if they did it would solve much hassel for all of us

no using createElement("img");
then setAttribute("src", preloadedimg.src);

how do css menus prevent text from beeing selected when you press a menuitem?

IRCFrEAK, try using new Image instead

is an image host the same as what createElement("img") produces though?
I mean can you append an Image into the DOM as is?

yep

hmm really… ok, I'll give it a try
as usual the existing code works fine in ff

how can i unset an array?
arrayname = "";
?

hmm nope, on the appendChild call IE says invalid arg… works in ff

XB23, delete arrayName
or arrayName = []
or arrayName = null
or arrayName = undefined

and whats newline in an alert?

\n

ta

..as in every other language, except possibly brainfuck
IRCFrEAK, you should try setting the width and height on the images

anyone in here used prototype library ??

hmm ok will give it a go,
nah still won't display more than 1 or 2 of them
perhaps I'm appending it into the DOM before IE has finished something

IRCFrEAK, let's see some code

ah
that works…
If instead of creating an img, setting the source, and inserting into the DOM, I set a function on the onload() of it to insert into the dom, they display
pah
it's a wonder anything works on IE

IE works. It just prefers to work in its own special way.

now I just need to work out how to stop IE ignoring my image caching
I tried switching to relative paths as some forum said, but still no go. It still gets the image every time I set an image's src to it

You want IE to cache an image?

http://www.pastebin.ca/654526 — What am I doing wrong? I am trying to insert target="_blank" to all anchors with rel="new" with JavaScript. Important to note is that "new" could be anywhere inside the rel attribute.

The paste 654526 has been copied to http://erxz.com/pb/4004

hi all, i need a help with YUI Libs, can somebody help me??

They better not, since they ignored me…

hehe
you Catnip96 ??

I don't use stupid libraries.
Codebloat = bad.

its bad way

What?

why loosing time when you can use something what is created

Catnip96, http://www.pastebin.ca/654533

The paste 654533 has been copied to http://erxz.com/pb/4005

http://developer.yahoo.com/yui/examples/dragdrop/dd-reorder.html

yahoo = bleh

there are two lists where you can reorder levels in avery one bloks and you can transmit levels between blocks

Really? You can do "var anchors = document.links;"?

yep
document.images too

i whant to lock transmitting levels between blocks
transmit==move

Is this some fancy stuff with bad support?

nope
works in all major browsers

Thank you, VistaBear. Worked.
I hope this is good practice too.

works in IE 7, opera 9, firefox 2 , I just tested, Catnip96
and also, safari 3 supports it
tested that too

Yeah… me also tested.
Safari is such a nice browser with its AA.

nah, the windwos version hangs

Have you got the latest version?
It has been updated like 3 times.

yep, downloaded safari 3 some five minutes ago

Latest doesn't crash for me.
Only sometimes.
But the earlier versions were horrible.

hang != crash

how do I append the items from one array to another?

Hang == crash!

ryanhanks, you wanna merge to arrays?
or just append list2 values to list1?

what might be the difference?

array.concat() ?

ryanhanks, list1=['foo', 'baz']; list2=['3', 'spam']; you want a list ['foo', 'baz', '3', 'spam'] ?

Is there a way to make a custom dialogue box in JavaScript? Basically, a confirm() but with custom Yes/No labels?

eval foo

foo

I am making a menu using javascript to handle events for showing and hiding submenus. How do I prevent text from beeing selected?

#join ubuntu-es

eval list1=['foo', 'baz']; list2=['3', 'spam']; write(list1.append(list2))

yes. that would be via the concat function?

''ERROR: Can't modify constant item in scalar assignment at (eval 212) line 1, at EOFsyntax error at (eval 212) line 2, at EOF

eval list1=['foo', 'baz']; list2=['3', 'spam']; write(list1.push(list2))

''ERROR: Can't modify constant item in scalar assignment at (eval 212) line 1, at EOFsyntax error at (eval 212) line 2, at EOF

hmz
concat, yes
eval var list1=['foo', 'baz'];var list2=['3', 'spam']; write(list1.push(list2))

''ERROR: syntax error at (eval 212) line 2, at EOF

thanks VistaBear, _Fallen

hi I wanted to hide my address bar after loading the a page, is there any way to do it?

I have never seen this problem on any webpage. There has to be a resonable solution. How do I prevent text selection in my js menu?

Don't try to modify the UI, Lastent.

Catnip96 why?

Because it's annoying.

ryanhanks, it seems you could use either .push or .concat. .push modifies the array, .concat returns a new array

Catnip96 do you know if theres anyway to do it?

Are you the bear in the sample video clip with a bear in Vista, VistaBear?

nope

There is a way, but you shouldn't do it.

ehh, I mean..
YES, I am!

:O
Is there a way to make a custom dialogue box in JavaScript? Basically, a confirm() but with custom Yes/No labels? Because the OK/Cancel makes little sense for a question that should be answered yes or no.

I am making a menu using javascript to handle events for showing and hiding submenus. How do I prevent text from beeing selected?

Catnip96, yes there is

standard js-popup with no window menu

however, it would require some clever css and position:fixed

Nah… that wouldn't be a native GUI box.
I don't like fake stuff.

then you would have to use alert()
or confirm()
etc

anyone, who can I hide the address bar?

use window.open
but in the end, it's not your decision

VistaBear but I want to do it after I load the window, see this is my problem, I dont have control over the link that pops up my window
VistaBear so I wanted to know if theres a way do do it before the window is poped

Lastent, that would not be possible

VistaBear is it impossible or you don't know how to do it?

you could use adressbar=no when using window.open

ppl
i am starting AJAX developing now, after i have some control over PHP
but i have a doubt

you cannot alter other pages other than the current one with javascript, and you cannot hide the adressbar unless you do it when opening the windows with window.open
Lastent,

i have a script that takes the $_POST array and, foreach $_POST, enters its value to the database
now, i would like to send data to that script

and still, there's no guarantee that the users browser allows you to hide the addressbar at all

"echosmile" at 71.6.194.243 pasted "open one, close the others" (30 lines) at http://erxz.com/pb/4006

if i was not using AJAX, i would make a simple form
with the action pointed to that script

VistaBear I got you

but with xmlhttprequest object, how can i send the data to the script?

who can help me with last past ?

i have seen the .send() method, but i dont understand how it works

how do I make a link out of a div so that text selection does not occur when selecting it?
vdc, google "xmlhttprequest tutorial"

i googled it
i've read it
but no tutorial i have read explains the send() method
at least well

I have a page that is useing javascript to poll a backend script every 2 seconds then append the new data to the page ( log file ). Is there any way to make javascript host scroll all the way down to the bottom of the page after every
update?

you could add data to top of page maby?

http://erxz.com/pb/4006 — no ideas for this?

wtz_ ?

have html form with some checkboxes that work great. when i user .innerHTML to replace the table that contains the checkboxes. and try this command document.memberdetail.monthly_assignment.length… i get document.memberdetail.content_package has no properties… not sure why this
is

oh no i don't want to try and read log files in reverse

You should fetch only changes ( use id of last entry as parameter ) anyway

when using .innerHTML its almost like it can see the form

clickable (instead of just the text link to the page name within)

how do I make a link fill a div so that the underline spans the whole div?
good question. mabe I am looking for the same answere

hehe, I believe so

wtz_ i only fetch changes, but the window doesn't scroll with the changes

you could catch mouseclick or mouseup events, but text selection will probably kick in and act strange
I am so fucking tired of having to write my way around this shitridden bullshit that is the w3c standard.

Alternatively you can ignore it and code by your own standards.

Browsers are struggeling with problems that were solved twenty years ago in standard gui's.
how do I build a solid house on a pile of shit?
Am I the only one thinking that html/css/js is less than impressive?

Do you have an alternative?

No, but I starting to get a considerable list of problems, bugs and design f*ckups, after using js/xhtml/xml/css/xslt for six month.
And it is all trivial, fixable stuff.

Looks like there's a lot of work cut out for you then.

Why would I want to spend my time solving problems that are allready solved in hundreds of computing systems allready? You do not have to be a brainiack to see that element layout in htlm is simply done wrong. Yes, I would do it differently. I would let text flow in boxes, not boxes in text.
That is just stupid!

have html host form with some checkboxes that work great. when i user .innerHTML to replace the table that contains the checkboxes. and try this command document.memberdetail.monthly_assignment.length… i get document.memberdetail.content_package has no
properties… not sure why this is
i can see that the page change with innerHTML but when i try to grab the value is get undef, makes no sense

Anyone seen the scene in Monty Python's Quest for the Holy Grail where the pesants are "working" with dirt and talking about social structure? That is me right now:-( What can you do? Nothing! Oh, right!

any idea why using innerhtml to replace checkboxes would make the value undef
uany idea why using innerhtml to replace checkboxes would make the value undef/u
whats that

How can I create/edit a table with JS?

Khisanth, why would i get document.memberdetail.content_package has no properties.

various things not working, stuff not being submitted, not being accessible with DOM methods, …

when it does
when i load the page it works fine only when i do innerhtml
i using onlick:javascript:function() — in there i try to access the values
maybe the onclick=javascript:function will not work when using innerhtml

hello
how would i get the row index and cell index within a function called by an onclick within a table td

Is it impossible to reliably disable submit buttons once pressed? Is this bad?

If Javascript is enabled, it is generally doable.
If it's important, use sessions or some other state, along with a page UUID, to prevent multiple submissions.

Naturally, this is not the only safety measure.
It is just to prevent idiots from clicking a lot on the submit button, causing extra load on the server.

You mean you're not handling credit card transactions?

I'm not.

How is that causing load on your server?

Like if they do a database search.
Two or more requests would be disasterous.
Because they just clickety-click unless they get a page back in 1 second.
So I would like a JavaScript to disable any submit button once it has been submitted.
Is this doable? Is it recommended?
I see that ImageShack.us is doing this.
They change the "upload" button so it says "uploading…" or similar and disable it.

disasterous????

Ok I found window.scrollTo(xPosition, yPosition), but i'm curious is there a way to get the y position for the bottom of the page?

is your server by chance running on a 486?

Probably a 4006 with a 110 baud modem :P

cute

So you don't know?

who me?

or input type="button"

I say you reassembled Colossus and wired it up some internet

Eh?

then use an onClick event to trigger a javascript function to change the value of the button to "uploading…", disable it, and then submit the form in the background using an Ajax or something

var Table = document.getElementsByTagName('table'); table.innerHTML = "trthMon/ththTue/ththWed/ththThu/ththFri/ththSat/ththSun/th/tr\n";
What's wrong with that code?
wait
ok, it's not the case
Am I doing somthing wrong?

yes solemnwarning .. you are expecting your code to return a single element the way you are using it
but it doesn't, it returns an array of all elements matching that tag name

document.memberdetail.content_package has no properties — i only get that error in firefix works on IE strange

Table[0].innerHTML doesn't work either

its a read-only array buddy

So how can I update the HTML inside a table?

so do myTable = Table[0] … then act on myTable

oh, thanks

then it should work

Still nothing

wonder why when using innerHTML for checkboxes, when trying to grab the value its undef in firefox but works in IE, strange

i think firefox is a more correct implementation of javascript… a checkbox would have no value… there is another way to check its state

document.memberdetail.content_package has no properties
[Break on this error] for (var i=0; i document.memberdetail.content_package.length; i++)
strange because if i hit the submit button for the innerhtml, then the innerhtml works fine, its almost like it doesnt get register int he DOM unless i act on it before theinnerhtml

you sure you aren't messing up the syntax or case-sensative variable names? I notice you used "Table" and "table" in your example which do not refer to the same variable

Yeah, that was a mistake
I fixed it
Still didn't work though
http://rafb.net/p/cvqti313.html
What am I doing wrong?

this example works fine: http://pastebin.ca/654630

The paste 654630 has been copied to http://erxz.com/pb/4007

what kind of errors are you getting on your JS console, if any?

None
The debugger doesn't show anything either

cause at first glance the code looks ok

install firebug

though because its a read only array I would assign the element to a new varaible instead of trying to overwrite Table

firebug? some firefox thing?

yup
firebug.com
and then install Yslow

erm

but other than that

That's an ad site

www.getfirebug.com

XD

actually, even though my docs say its a read only array you can still change the value of the returned elements without assigning them to a new variable. i just tested and that works, so i'm totally lost why yours isn't working

w00
It wasn't that code

oh, ok

The function that was supposed to call it had an error _
Still doesn't work in konqueror

which version of FF are you using ?

iceweasel 2.0.0.4 for the firebug thing
I normally use konqueror though

i would never be able to debug some of my JS problems without the FANTASTIC firefox JS console
just the default one helps a ton

if you think the default console is good, then firebug will just blow your mind with its features…

i'm going to look at it now

hihi all

for some reason

you are right thecoolone19 … very cool. this should definitely make CSS editing MUCH easier
and i'm sure it will help with JS too (though i wasn't having many problems there)
uand i'm sure it will help with JS too (though i wasn't having many problems there)/u
jscript.net? please don't tell me thats .NET with javascript syntax

Um. I guess so. Why?

if you want to make CSS editing easier then you need to get the "web developer" add-on for FF
bif you want to make CSS editing easier then you need to get the "web developer" add-on for FF/b

in my code get its own tr?

that just sounds ugly… javascript (a scripting language) being used to make full fledged apps

Is it somthing to do with innerHTML?

hi all
i want free maskedit control for my php project

I put it to you that it is a lot less ugly than using VB to make full fledged apps.
Plus it's fairly well extended. Strong(er) typing, proper classes, etc.

inside a tbody

wth is a tbody? somthing to do with js?

All tables have TBODYs
they're just usually created implicitly
If you're making a table using javascript and DOM methods, you must explicitly create it, append it to the table, and put your TRs inside the TBODY.
Yes, this is strange and confusing

Jan`: you're right… suppose it couldn't be any worse than using VB

It's not really javascript, it's the way HTML rendering works.
well, I think it's a good thing, because it means people with jscript experience from the web are a lot of the way towards being able to write proper apps.
So, I'm in favour.

Adding them all at once worked, thanks

try storing all the changes you want to make to the table in a variable and then dump them all into the element through innerHTML at the end

I think the reason it exists is so ASP people can write web services.

that way you don't get caught by the browser who is trying to build the table for you as you go

Unfortunately, I'm having to learn what "assemblies" and "interfaces" are.

Any suggestions why this code works in FF but not konqueror?
Am I doing somthing obscure? is innerHTML non-standard?

i don't mind seeing higher level scripting languages used for application building… that can be a great idea… I just never really liked the .net stack and cringe a little when i see a language i like (javascript) implemented for it

I cringe when I see javascript :|

lol

Yeah, well, you're just one of those people who can't stand to see nobodies like me creating .exe files

javascript itself is a fantastic little language… unfortunately its implementation in web browsers is sometimes horribly inconsistnet
*inconsistent

i want free maskedit control for my php web hosting project any one can help me.

Well yeah, but that doesn't mean much here.
I'm not running it in a browser.

hello

Jan`: no, thats not it. i'm really just a scripter, but i make full fledged executables using python and have even played with making GUI interfaces using PHP

I'm having all kinds of trouble making it run UI applications.

hey, how can I "capture" the paste event in an editable HTML?

Theoretically you have access to all the usual windows forms and controls.

Anyone?

i just don't like .net… whether implemented through javascript or C# or VB

What's wrong with it?

sorry man… not familiar enough with konqueror's javascript implementation

bah
damned javascript and it's varying implementations

like i said, you may want to build you table in a string first before pushing it into the HTML element

… I believe paste has different keys in different browsers, like in windows, it's ctrl+v to paste, or shift+insert

Is innerHTML "standard"?

yes

I have done

ew, don't tell people to use innerHTML

It's working fine in FF now
Jan`: Is there any alternative?

well… he just asked if its standard

I believe the colloquialism here is "innerHTML ftl"

but is there a way to hook a function to the paste event?

I've never had a problem just building tables in DOM code.

i didn't tell him to use it… though i've used it many times, as unfortunate as that might be

DOM?

document object model

Would that be a better thing to use?
Or is it even less portable?
Jan`: At least perl is perl

Perl was quite clearly designed to even out keyboard wear on the non-alphanumeric keys.

There isn't a perl for differant platorms/whatever
_

i'm pretty sure Jan` is suggesting you use the Table.deleteRow(), Table.insertRow(0), row.insertCell(0) and such
which are some of the DOM methods for building a table
and should be equally or more portable than building strings and pushing them into innerHTML
which is very error prone

It's verbose, but it doesn't have unpleasant side-effects with event handling and form submission.

for now though i'll continue using innerHTML to accomplish things the quick and dirty way
because if myspace has taught us anything, it has taught us that people are accepting of quick and dirty interfaces

That don't work in all browsers
Since KHTML can't even render the table….

i'm going to install konquerer i guess… i use it a lot so it would be nice to know if its working

Aaar!

i don't innerHTML tables much though

*hop* *wail*

Safari uses the KHTML engine too

you can download safari for windows now

aaaa! oooo! Eeee!

elements

I use innerHTML when I need to clear the contents of a tag
no need for fancy removeChild()s

so, is there a way I can tell when something has been pasted in an editable html ?

while(foo.firstChild){foo.removeChild(foo.firstChild)};
I tend to have empty() proto'd onto Object for things like that

Jan`: foo.innerHTML = ""

foo.empty()

Maybe I should clear the page and redraw the whole damn thing with document.write()

lol

Would that mess up the forms?

Jan`: is that even going to work on most browsers
?

don't think so… not if you redraw those too

ok

in an editable HTML, how can I get and set the cursor position and selection?

Is there a way I can clear all the text printed with document.write()?

Wooo!

hey all — can anyone help me out with a probably simple prototype/JS question?
hey all — can anyone help me out with a probably simple prototype/JS question?

Back, you!

what is "an editable HTML"?

a document with designMode = 'on' or contentEditable = true (IE)
that's what I mean by editable HTML

read up on document.selection and document.createRange

JLearn, is that applicable to all browsers?

No, selection object is IE only

that's what I meant… I need it in FF too and Opera, safari, etc…

But what are you trying to achieve? Create an online editor of some sort

yep
exactly

the other zillion solutions aren't good enough?

I have it almost done… just paste detection is missing for some things
well, I just want a lighter version

Use an existing WYSIWYG editor if you need something like this, much better.

I tried, but they're huge even the "Tiny" ones
plus I don't need that much funcitonality
(just simple BB WYSIWYG edition)

OK then lookup some free ones and see how they do it

what about the phpBB editor?

I'm not sure which one it is anymore, I've seen tons

anyone still kicking?

I based my editor in OpenWYSIWYG

hey
trouble with changing radio label style/className..
here's the function

(initially, but now I've rewritten and changed everything)

http://www.pastey.net/72135
it works, if i alert the element's color after it's set it shows set, but in browser window the color doesn't change

hey, what's the name of the utilities to "compress" javascript?

you can't compress js

is there an easy way with javascript to select a select option by value and not by index?

yes there is.
not easy tho

GOogle for Javascript obfuscators

well it's easy but loops

so i must go through the options and find the index that has the right value right?

http://javascriptcompressor.com/
if you really care to save 1k ..

I now just need a way to get/set the selection of the HTML editor

Is there a way I can clear all the text printed with document.write()?

anyone on radio label style?
http://www.pastey.net/72135

And can I use document.write() without erasing the HTML that's hardcoded into the HTML file?

No you can't.

ok

try php or asp

For CLIENT side processing??

no, for inline dynamic content

If I was doing this bit on server-side I'd use a decent language, like perl :P

or a mature language like Java.

bah

Hi all.

Hello.

Why does http://www.quirksmode.org/js/events/keys.html generate two JS errors per key press in FF?
I'm using FF 2.0.0.x on Mandriva Linux Cooker

I guess there is some problem with the site.
That example used to work fine before.

OK.

hey guys, if i have a div object, is there a way of walking the div so that i can find all the other child objects

yes, see the DOM.

Look into the childNodes property of the div object.
var d = your_div_element; for(var i = 0; i d.childNodes.length; ++i) { //do something with them; }

rindolf, JLearn, aha thanks guys

hello

Hello

can't I and an event by using the document.getElementsByClassName

what? Can't I and?

like I have this php code the generates lot's of buttons and I am trying to add an onclick event by using the document.getElementsByClassName with the Event.observe
like the buttons all have the class name img_editar_btn
and I want to get all of them and place an onclick event

When you are generatign the buttons dynamically, attach an onclick event handler to them.
Or write your own method called 'getElementsByClassName' and loop through the elements to attach the event handler.

JLearn well I know I can do that but I was just trying to use js to get this done

I am talking about JS

JLearn php is generating the buttons not js

*sigh*

I want js to go get the buttons php web hosting generated and add the onclick

Like I said write your own method called getELementsByClassName()
call this routine as soon as the body loads using the onload event handler of body.

How much JS do you know?

but what is the problem with using the prototypes function?
it returns the elments
I am just not getting the onclicks

how are you assigning the onclick event?
var buttons = getElementsByClassName("hello");
for (var i=0; ibuttons.length; i++) buttons[i].onclick = myFun;
like this?

I have already suggested that. The OP is talking something about using Prototype library's Event.observe method.

no no I was using the prototype function
but I think that's the problem
document.getElementsByClassName('teste').each(function(element) {
Event.observe(elment, 'onclick', function(event) { alert("OLE"); });
this does not work
elment = element
but if I do element.onclick = function() { alert("TESSS"); }
it works fine

what if you don't write the "event" in the function parameter?
function() { alert("OLE"); }

I am now confused.. shouldn't the prototype work??

Event.observe requires 'id' to be its first parameter and not the element.
You need to pass the id.

JLearn oohhhh

change element to element.id
It should work

JLearn the buttons don't have id's
I can place id's I guess

give them ids

Acs, it's "click", not "onclick"

VistaBear I know
I just changed it to see if it would work that way

Ooh! a BEAR!

thanks

Heh

can i change background of some input element with javascript?

yes

although you remind me of my dad :p
no offence though

JLearn, how?

Ewww!

it's just the name :p

and i meant background image

JLearn

Yes

in prototypes page, they give an example

Oh. Well, I guess he's just called Jan, whereas my Jan is short for something else.

that allows you to click everywhere on the page, and they do this by passing the document.body

Is the id thing working or no?

haven't placed id
just gimme a sec

use the backgroundImage property

er

is iframe.contentWindow a standard property?

Awee!
*squeeze*

JLearn, if i have an input type="image" as submit button, do i use onsubmit or onclick event?

There is no type = image

of course there is

Then I don't use it a lot

there is one, don't know if it's standard though

yes it is

Are you developing for IE, because IE web developers have a lot more than the W3 has to offer :P

its been standard since…ie5.5 i think

like document.selection, document.createRange yada yada

maybe even earlier

JLearn I just tried this with divs
and it worked

Nice

but it won't work ti the form buttons

http://www.w3.org/TR/html401/interact/forms.html

which is what I want

http://www.w3schools.com/tags/tag_input.asp

does the job for me.

JLearn great

I found what the problem is.

What is a way to get the length of the full html page?

by document.forms[1] it referred to the wrong form.
because the search form had been added.

So should it be document.forms[0]?
I didn't look closely, just saw the errors on FF console and knew there was some problem with teh code itself.

no. document.forms[2]
I'll email the admin about it.

well, its defenitely onclick

good

strange…
now it works

JLearn, i think that up there is a …bit wrong

lol

why would you add onclick on image?

thanks for the help guys

because my application specification requires to.
You are welcome.

I thought you first include img betwen a and add onclick to a tag
:-)

thats only when you plan on not doing any client side processing when the link is clicked.

plan on not doing any client side processing?

when I just need an image as text placeholder.

It doesn't make sense to add onclick handler to anchor tags. I can do the same by adding the handler to the image tags.

people usually want to "link" image …
yes but then image won't act as an link, having mouse over it wont change anything , right?

CSS anyone…

css wont help cos its not an link

css classes anyone…

#css

Thanks for the redundant link.

redundant?

heh

strangely enough that page is nowhere on the sitemap - neither in archived or in active pages.

Hmm..did you mail the admin?

no, not yet.
he has some rules for mailing him.
to get a good response.

Even when it is something concerning the way his site is functioning?

http://www.quirksmode.org/contact.html

The project required us to not allow the users to go back and hence the onclick event of the img invoked location.replace('someurl'). No need for putting that extra anchor when we didn't need it.

how do you select certain parts of an HTML… I see it's done using ranges, but what's the procedure? should I create a new range for the document and set it's start and end nodes and offsets… and then what?

read up on this thread and follow the links specified. http://www.daniweb.com/forums/thread85642.html

thanks
hey, is there something like macros in Javascript ?

AFAIK, no.

hey, are contentWindow and contentDocument something I can always find as iframe's methods?

should be able to yeh
as long as u specify the name of the window

hmm… I wonder how come I have some code hwere that has some tests for it as if contentDocument wasn't there in IE or other browsers
if I have a pair of nodes and offsets, how do I select something in the HTML tree ? (that works in all browsers)

hey, can anyone tell me if I use the split method and there's only one item in the list, does it return it as a string in the first index of the array?
or does it just treat it like a normal variable instead of an array?
I'm almost certain it's the first one…but just want to make sure

its always an array AFAIK

split *always* return an array.

I'm doing some animation work with javascript, what is a good way to set the rate it changes?
should I use the self calling setTimeout()

window.setTimeout or window.setInterval
if you use setInterval be sure to clear it ones its done.
i.e. var interval_id = window.setInterval(…); window.clearTimeout(interval_id);

would I nest that?
the example I found:

thanks for the reply fatbrain
and JLearn

showingrow(){ /* does stuff */; t = setTimeout("showngrow()",timestep)

no, you don't nest.
nor do you pass any string content to the setTimeout/setInterval

so window.setTimeout() makes the program stop and wait? for that timeout

no, http://developer.mozilla.org/en/docs/DOM:window.setTimeout

http://erxz.com/pb/4006 — can put with this code, close the others when click in some link?
a href="http://erxz.com/pb/4006"http://erxz.com/pb/4006/a — can put with this code, close the others when click in some link?

thanks Ill look

is there a way to get the number of a node item in a HTML tree ?

Kronuz, you can use the .childNodes method I think
search for it at www.mozilla.org/docs/dom/domref/

that'd be for direct children only… I guess

Kronuz what do you know about the item?

all nodes? No matter the depth?

id, name or are you calling it via this

melkor, I have the node object itself

not really Kronuz, you could sue a for loop, it returns an array I think
use*

is it possible to send the top-level document to a different location if the user clicks a link from within a cross-domain iframe?

yourNode.getElementsByTagName('*').length

or something?

Woosta, that would count the number of children my node has, won't it?

unless you also want to count comment nodes and text nodes .. in which case you'd have to do a recursive count

Kronuz, you want the index of it if you had to 'walk' through the html tree?

that will count descendent nodes

yeah, that's what I thought… I'll have to walk the tree

what is it you actually wanting to do?

from html to my node

You can check it with an '==' though.

I'm working in an undo/redo system for my wysiwyg editor

hi there!! Can I execute a binary program in the linux/unix platform in mozilla?

oh

of course not

there it started working

I still can't figure out how to select a portion of the HTML using javascript

so why do you need to count nodes?

do I just set the range after creating a new range?

what do you mean by "the number"?

Woosta, not even from within an extension?

deltab, well, if I later rebuild the HTML source and after an undo I want to select what it was selected at that time, the node objects will probably not be the same but the "node number" would

no, it would be a stupid extension if it did exist

woosta could you have a script run a cgi?

ut is it possible for my needs to develop one? I mean, does the mozilla/chrome/javascript framework allow me to?
but*

JS can make http calls, if that's what you're asking

its called ajax :p

kronuz can you keep track by the id tag?

nope
not all nodes have ids
say I have a node pair and their offsets, how do I select that range in the HTML using javascript?

hm.. so Woosta I should take "if it did exist" as "it is not possible for one to be created" ?

firefox is open source, you can do anything you want

revil what do you mean you want to run a binary file? You could call a .cgi file and it could run anything you want.

he wants it run on the client machine

oh

http://phpfi.com/255915 - how to do to execute "onclick" first?

The paste 255915 has been copied to http://erxz.com/pb/4012

You know scriptdocument.write(system('cat /etc/passwd'))/script

melkor, I mean I want to add a chrome/javascript extention, thus portable, that can allow the local user to execute an arbitrary program, e.g. a specific unix binary text editor.

probably the best bet would be to use a pseudo protocol

greetings everyone

textedit://your.url/here
But after it opens the text editor .. what next?

can I install a pseudoprotocoll?

attachment

then the extension's work is done

what do you mean?
the browser executes it

it was my fault - wrong function name

argh!!
I tried document.createRange() then setStart and setEnd over that range, but it seems it's doing nothing

are there any typical things that aren't real javascript errors but makes IE show "there are errors on the page"?

what is the best way to walk the DOM tree ?

js_ there are quite a few functions that work in mozilla and not in ie.

it's strange because sometimes ie complains and sometimes not

Kronuz, xpath, but that's not supported in IE

it's of no use to me then

Hey I'm trying to make it so that clicking on a link (a onclick…) changes the content of a div, but also need it so that if javascript is not enabled, the href is not follow. So far I can changed the contents of the div, but the link is always followed. How can I stop this please?
Sorry, for some reason tonight my English (native language!!!) is very poor. Please excuse it.

Kronuz, what do you wanna do? you could just loop through alle the childnodes of html

VistaBear, and have a recursive function, right?
what about non-recursive solutions?

no recursio should be needed
childNodes provides all child nodes, no matter which nesting level they are in..

hmm

hm

really?

no

I didn't think so ^_^

childNodes doesn't, sorry, but document.getElementsByTagName('*') does

not with an xml file.

okay, that'll return an array, right?

Kronuz, almost
dom node list

Hey I'm trying to make it so that clicking on a link (a onclick…) changes the content of a div, but also need it so that if javascript is not enabled, an href is followed. So far I can change the contents of the div, but the link is always followed. How can I stop this please?

return false

okay, should I add this to my function?

yea, if you were doing it inline it would be like this:
a href="linkval" onclick="manipDiv();return false;""

I see. Cheers!

so you can add return false to manipDiv() and it should work

no
in JS you need to explicitly return a value

It seems not to work adding it to the function, but adding it inline does the trick.

so you'd want onclick="return manipDiv()" to pass on the return value of the function
'false' in a void context is meaningless .. there's no automatic-return in JS

Ah I understand. Thanks for clearing that up.

np

Woosta, there is
"undefined" :p
javascript:alert(typeof (function(){})())

no, that's not returned, that's just the result of calling a function without an explicit return

http://erxz.com/pb/4006 — something wrong with my questions ? i can't get any feedback

that won't show me the text nodes
getElementsByTagName
I need to walk the tree seeing those too

then just do a loop over childNodes?

recursive?

or possibly use parentElement.elements
Kronuz, please tell me exactly what you wanna do

consistently assign a number ID to each and every single node in the DOM tree
like the html node might be node # 0

Kronuz, you cannot do that on text nodes..

Iof course it's possible… I just need to traverse the tree (non-recursively preferibly) and assing an ID to each node (even text nodes)

Kronuz, have you tried? I highly doubt that a text node can holde an ID

the ID is my own
not to put in the node

consistently assign a number ID to each and every single node in the DOM tree

Is there a way a CGI script can check if the browser supports javascript?

that would mean setting the id attribute on each node, right?

no
that would mean the algorithm is stable

solemnwarning, no, but you could hide a field by default, and make it pop up when js is activated

it would return the same id for the smae node given the same tree structure
but I just don't want to use a recursive solution…

so basically, you just wanna count each element, Kronuz ?

it's been ages since I last created a non-recursive tree walk

parentElement.elements[]

can anyone tell me how variable scope is calculated inside a function? is it from where the function is called?

VistaBear, that won't work if the parent has a parent

then just find the first node in a document

are there reference variables in javascript?
referenced*

yes, most are refrenced by default

(like if I pass a variable to a function and that function modifies its value the variable gets modified when the function returns)

Kronuz, take a look at http://developer.mozilla.org/en/docs/DOM:document.createTreeWalker
you could pass in a dom-node and that kinda a thing would happen

I've Got A Small Javascript Problem, Can Any1 Here Help?
sorry forgot to diable color :P

VistaBear, nevermind, I think I have it now
(used a non-recursive tree walk algorithm)

I've got a small javascript problem, can any1 here help?

no, where it's defined (lexical scoping)

Anyone have any idea why a function would become undefined when written by a function?

"when written by a function"?

#
document.write("input type=\"button\" Value=\"all\" onclick=\"all()\" alt=\"all\"");
like that

it works fine

but when it's written with document.write it becomes undefined
:| anyone here?

deltab, so the only way is to pass the variable/variables as an argument? sounds really ugly
deltab, would an anonymous function act the same way?

yes
you can't pass variables, only values

deltab / Hor|zon
can either of u help me?
ffs, to undernet ;-;

is it possible to use things like getElementById without writing object name? For example, not "document.getElementByid()" but just "getElementById()"
like "with Font do begin" in pascal

hey, will a range always be a pair of text nodes and offsets?
no other type of nodes but text?

It seems like animations using svg are very slow.

yes, but it's a bad idea to use it, and it'll be probably be removed in future versions of the language

why?
and how to use it?

hello
anyone know how to prevent an enter from submiting a form

http://www.javascriptkit.com/jsref/statements.shtml

I have placed a return false; and window.event.which = window.event.keyCode = 0;
but it just submits

shal3r, is it possible to use things like getElementById without writing object name? For example, not "document.getElementByid()" but just "getElementById()" — yes there is

it's easier just to use $()

because it becomes impossible to work out what a name refers to until runtime, by checking the properties of the objects, which makes your code slower, hard to understand, and fragile (if an object has a property you weren't expecting, it can mask the one you wanted further down the chain)
because it becomes impossible to work out what a name refers to until runtime, by checking the properties of the objects, which makes your code slower, hard to understand, and fragile (if an object has a property you weren't expecting, it can mask the one you wanted further down the
chain)

shal3r, http://norskwebforum.no/pastebin/9257

acs do you have the onsubmit="return youFunct()"

thanks

but as Acs said…

melkor no
I just have it on the onkeypress of the input

does anyone know how garbage collection work with for loops? and does it affect performance?
like instead of defining a variable inside the loop is it better to define it outside
or does it not make a practical difference?

melkor thanks
it works now :P

my thinking goes defining it outside the loop and simply assigning inside would prevent it from being closed and so it doesn't have to be recreated on every iteration…or does it not matter?

hi all

or is it maybe slower to have to reference the memory location again rather than create a new one?

how can get the html output of my iframe's?

this.parentNode.parentNode; - In FF it works fine in IE it says it's null

Yns, frames['yourframe'.innerHTML]
Yns, frames['yourframe'].innerHTML *

Acs, var foo = this.parentNode; var bar = foo.parentNode; ?
woops
well you get the picture

Acs, it might still be good

tried that?

Hor|zon I just tried a few alerts and I get [object] for this and I get undefined for this.parent
so it's saying that it has no parent
when it does

so the problem lies with this

well at least in FF it does
I think so, yeah

even though it says null, you could do this.parentNode.parentNode.nodeType ?

are you sure "this" is referencing the right object?

Hor|zon it's a function that is being called on the onclick event of a button
in FF the this refers to the button element

near the root of the element tree?

in IE I just don't know
deltab it's one up
the root
that's why I do parentNode.parentNode
ops, 2 up

VistaBear, firefox js console says that; no properties..

I think I might have to change this

Acs you can do one .parentNode with IE, do you get a nodeName?

i've got a form that submits to an external site. onsubmit, i want to pass the user-entered value in the query string of a URL…how do i get that value?

melkor nope
nothing
it gives me undefined

how is the handler attached? by setting onclick?

deltab prototypes Event.observe

are you using bindAsEventListener?

hhumm no no
because it worked great in FF :P

'this' probably refers to the global object (window)

yeah
thanks deltab

anyone?

okay, I've tried it all (I think) how can I select part of the HTML if I have the start and end nodes and the offsets ?
I tried creating a range and setting the start and end to the nodes and offset
that doesn't give me any errors, but it just doesn't select anything in the screen
what am I missing?

deltab
I am now using the bindAsEventListener
getting a [object Object] but if I do like this.id I get null and it has an id

where can I see the code?

hhum you can't…
it's a mess
thanks for the help anyway
it there any function that will show me all the attributs of an element?

on http://developer.yahoo.com/yui/examples/dragdrop/dd-reorder.html there is an interesting use of "(function() { some_code_here; })();" — i was wondering if someone could explain how that works? why does ()(); run
but not function(){}; by itself?

" + x[p].toSource() + "\n");
or, if you're using Firebug, inspect(x)

I am using deltab
thanks

I jsut installed windows SP2, and ive suddenly started getting a "page wont display correctly" message from *cough*windows*cough*. What element is causing this? Im only useing the javascript for a dropdown menu. Got it off of javascriptsource.com

deltab it said inspect was not defined

with window.location, if im putting some values into a URL's query string with PHP, do i have to url encode them?

try going to tools / internet options / security, and reset all the zones to default

arrgh!
there's no setSelection method

the for in says this has no properties

try console.inspect

it still says it's not a function

hmm, well it's listed in http://getfirebug.com/commandline.html
yes, values put into a url should be url-encoded

now I Know what it's refering too
to the var
hhumm I think the binding thing was a bad idea

how so?

how do I visually select some part of the HTML using javascript ??? (as if I had used the mouse to select it)
I have the range… now how do I show it in the HTML ?
please, someone help me

I'm having trouble figuring out how to change the title attribute of a table cell using javascript DOM

cellElement.title = titleText;

wow that seems way to easy

dammmit! are the guys who created IE stupid!?

and it worked just fine
now can you format title boxes?

they use the same method names for different stuff in different objects and even then none is intuitive and they all are seemingly random chosen names

Morning all
Yet another question
I'd like to be able to protect the global namespace and want to create a unique namespace for the methods I create

how do you suppose gmail creates the little popup when you hover of a contact in your contacts list

tooltip
Quite a few of the JS toolkits provide it

protect the global namespace from what?

I use the one from Yahoo
"them"

haha

Ok, so I want to look fancy and have my name at the start of function calls

var namespace = {};namespace.funct = function() {};
that should do it//

Thanks!

np.. you can look at YUI's namespace object to see how they do it
but that's basically it

Because I'm a bit of a neat freak, is it possible to define a hierarchy and have methods sit at different levels?
Good idea..
They're libraries are _really_ handy

sure, and well written

where i can see javascripts menus?

Sure are!
http://developer.yahoo.com/yui/menu/

http://erxz.com/pb/4006

find menu

v
http://developer.yahoo.com/yui/yahoo/#namespace

;google suckerfish

http://www.alistapart.com/articles/dropdowns/

Who moved that ctrl key

^^ echoSMILE see suckerfish

good tip - thanks

but it's not JS .. JS menus suck .. use CSS

np..

Woosta to hide and show div's ?

This isn't enough?
http://developer.yahoo.com/yui/examples/menu/programsmenu_source.html

or var Namespace = { foo: function () { … }, bar: function () { … } };

Thanks… of to try both

like, i use that code that work fine, but i just change one little thing. when click in some link, all submenus close except where i click
just that
hard to change this code do to that ? http://erxz.com/pb/4006

how come document.createRange() is a selection and not a range ??
I'm all confused now
there's anchorNode and startContainer …and fousNode and endContainer
I'm all confused now… and this is just for FF
I can't imagine how IE, Opera and Safari will do it

When I do drop down menus, I change the height of the div element that contains my menu.

hey, how come this isn't calling updateHistory() after my ajax call is ran? http://hashbin.com/78a5.html
it calls the ajax fine, just that the onComplete isn't being evoked.
figured it out… there's no () after updateHistory. [now the question is why]

Event.observe does accept an element for its first parameter
a-l-p-h-a: because you have to just refer to it at that point, not call it

hey
does splice return the element it removed?
I am trying this out
var teste = "ole_olas".split("_").splice(1,1); alert(teste) - And I get Olas

elements, yes
var teste = "ole_olas".split("_").splice(1,1); teste.toSource()

["olas"]

deltab, thanks. that makes sense now.

[], {}, function(){}
anonymouse ? static ? i forget…

http://nopaste.com/p/ati8kkE7y - I'm trying to retrieve a "direct" preview of the entered part into the textarea by clicking on a submit button, preview.php just contains echo $_POST[motd]; but the method doesnt work (empty page) - does anyone have an
idea?
hope it's still js related

anyone know if there is a function to refresh the page
to reload the page

I just can't make my region to visually select stuff in the HTML
that's about the only thing missing in my simple WYSIWYG
(wich is only 60K uncompressed atm)

How do you force an integer to be a string so + works as concatenation?

(3).toString(10)

3

var ssn = "q3dfa35asdfd335aaa 1122"; print(ssn.match(/(\d{9})/g));

null1

var ssn = "q3dfa35asdfd335aaa 1122"; print(ssn.match(/(\d)/g));

3,3,5,3,3,5,1,1,2,21

How is {9} invalid?
Nevermind I'm retarded, I got it

:-D

hello, everyone

hello world\n

haha
hello dav7

Hi W0RLD

-.- seriously, once was enough

mk

hehe

lol, anyone doing anything exciting????

yes
dun ask me tho, I've been sworn to secrecy

hm?

^_^

-_-
=P
ohhh
if the whole world gives you a cookie i think it might be really big =P

hahhahaha
well, I'll respond in ##dav7 :P

hello, zumbrunn!

I'm having trouble assiging an onclick function via DOM

hello, jherrera!

hey W0RLD !

i've only had this nick for about 2 minutes and it's hilarious =]

yeah, I see

oRow = function() {myFunc(data, i)}, I being the row of the table i'm creating, but I always end up with the last value for i
so I'm doing something seriously wrong here
can someone tell me why I have to change elm.onclick=function(){myfunc();} like that and not elm.onclick=myfunc();

elm.onclick=myfunc;

elm.onclick=myfunc() will fire right away and not on click…

No () and it will work

well i'm trying to call it with some arguments

function(){myfunc();} will not fire ever

Then yes, you need the anonyfunc

I have a for loop that is appending table rows, and I need to pass the number of the row to myfunc

Then you'll need a closure
Otherwise the last row's handler will be called for all of them

can you explain that?
yes that is what is happening

`closures @ hmmhesays
`closure @ hmmhesays

the bot dead?

he's not .. he's just .. misbehaving :-D
`closures @ hmmhesays

closures: http://jibbering.com/faq/faq_notes/closures.html or http://blog.morrisjohns.com/javascript_closures_for_dummies

where can i look up documentation on what variables are provided by the event object from an element callback ?

Is there a function to create a new element and copy the contents exactly of another element into it?

clone child or somethig

`dom ref cloneNode @ wescotte

dom ref cloneNode: Returns a duplicate of the current node. (http://developer.mozilla.org/en/docs/DOM:element.cloneNode)

I know of no reference document sorry
If you find one, please let me know so I can add it to the bot

so i cant get docs on what the variables would be for the mouse position ?

"bobross" at 71.6.194.243 pasted "Newlines do not display in IE7, the code is all run together" (29 lines) at http://erxz.com/pb/4015

Any ideas?

do i just use screenX/Y on the window object ?

no idea
I never play with mouse-position stuff

you never wrote drag code ?

nup
Only time I've ever done drag stuff, I've either used scriptaculous or draglib

Ok, reading through this I'm not sure what I'm doing wrong then

if I performace a replaceChild()… Should/Can I destroy the old child?
or do I just leave it and the garbage collector will get it?

The garbage collector will get it unless you still have references to it

.whis Woosta

I understand the concept of a closure, I'm not sure how to create one in this instance

for(var i=0; i n; i++){ foo[i].onclick = makeClosure(i) } function makeClosure(o){ return function(){ reallyDoThis(o) } }
That 'closes over' the value stored in 'i' in each iteration

yes, that makes sense

is it not onMouseDown ?

onmousedown .. case sensitive

I think i'm going to call the function makeClosure
but wouldn't it be for(var i=0; i n; i++){ foo[i].onclick = function() {makeClosure(i)} } function makeClosure(o){ return function(){ reallyDoThis(o) } }
because I don't want it to fire when I create the table row

don't call it make closure .. call it what it does …
you might find your self using TWO closures, then what will you do?

 JSP Web Hosting | JSP Hosting

*
To prove that you're not a bot, enter this code
Anti-Spam Image

Leave a Comment

You must be logged in to post a comment.


Blog Tags:

Similar posts: