I have a load of checkboxes all called industry[] so that they become element in an array when the form is submitted
kon, but I don’t know the iframe’s id.
I dynamically created it, now I want to remove it
when you have created it then you should have a reference, right?
the reference is in the outside document’s variable.
And there are a bunch of them
Is there no way like. document.window or something?
which gives the container object for the current iframe. I am sure you have to some way run up the heirarchy
parent?
top is the root, parent is the next upper node
so document.parent.parent.parent…. will eventually give me the window?
window.parent
OK. It seems that doing “window” inside the iframe gives me the reference to the iframe. How can I use this reference to destroy it?
I can also determine it’s name from the inside, but not it’s id
window.parentNode.removeChild(window)
ah HA!
thanks. that should work too
window.frameElement.id
this gives the id
I love firebug
yes firebug is lovely
hey, can someone tell me what is wrong with this function http://pastebin.com/m583e0de9
How do I remove an element, because I am getting a BAD_CONVERT exception
it adds the new row, but doesnt increment the hidden value
fifo_, you get this error when using removeChild?
kon, yes
i don’t know fifo_
nv
Got it
window.parent.document.getElementsByTagName(“body”)[0].removeChild(window.frameElement);
window.frameElement.parentNode.removeChild(window.frameElement);
that does it
ok cool
thx for your help. would have still been stuck without some of those tips
This is just so awesome. Now have have a memory friendly XmlHttp fallback
The browser started getting lank slow after a while
you’re welcome
hey, know any good js debuggers for ie?
hi…
i want to show an image submited by a form before the user submit it …
so i created an “img” element but when i want to put the input.value in img.src, img.src is equal to ‘http://127.0.0.1/’+input.value …
any idea …?
(i just want to img.src to be equal to input.value, without the ‘http://127.0.0.1/‘)
come on, guys …
faster you answer, quicker i get out …
is there any problem in my enonciation …?
is img.src really equal to that?
browsers usually prepend the host before urls, but I don’t know if this causes the complete url to appear in javascript as well
when i alert(img.src) it’s what it tell me …
if you want to access a local file you have to put file://
hm…
exact …
i try …
good …
thx …
but you can’t give a file-protocol located file to an img.src …
hi. can someone tell me what direction I should go in taking a $_GET value in javascript?
By default, Firefox does not allow loading local addresses.
maybe the answer …
I’ve written in php and such… but never in js
thx guys …
atula, it’s ajax concept …
hmm… I didn’t think that was the case
no, wrong …
if ($_GET["variablename"]) {
scuse me …
do something
}
I mean… AJAX takes from server… not from a line
…. GET
try the form element document …
atula, http://developer.mozilla.org/en/docs/DOM:form
i’m gone …
body {cursor: auto}
does anyone know why this is?
or how to fix it?
dont change the cursor
seriously
dabear, I thought it was a bad idea and I’m probably going to do it differently but I was wondering if this was a known thing
I just want to change the cursor for a split second while something loads
I have a coldfusion passing a variable to a nother page in $_GET format… how do I get it with javascript?
is it possible to do something like this: load() { doSomeThingHere(); } and have the load() method execute some code before and after that function?
(something better than change the cursor, I promiss)
atula, location.href
thanks. I’ll read about that
Juice10, look at unload or something
Hello guys
I having strange trouble
dabear, its not for page loads, I just want nice code
window.close() not closing window
Window is popupped by wysiwyg web hosting for online images wizard
even self.close() not helping
its better than load(); doSomeThing(); getRidOfLoadingThing()
Juice10, using ajax? there’s a status set when the request has loaded, in prototype this is mapped to the onComplete function
atula, window.location.search
Can somebody advice me?
dabear, yeah I know but the code sucks, I’ll have to add onComplete & onLoading to everything. Not very DRY
GhostBear, code, please
hmmm… so there’s no such thing as the equivalent of $_GET in javascript host eh…
as you have described it, there shouldn’t be any problems
atula, no, you must make it your self
not that hard, really
I guess I’ll use the var stuff = location.href and break the string apart to search for it eh
yep
gay
alright…
thanks so much, dabear
atula, location.search, use that one instead
that will give you the query string
atula,
do this:
So any suggestions?
var stuff = window.location.search.slice(1).split(‘&’) and then loop through each key and split on ‘=’
value*
GhostBear, hard to tell when the pastebin never loads :p
o_o
Tjeneren på pastebin.tom.ru brukte for lang tid på å svare.
e.g. the server at pastebin.tom.ru used too long time to answer
http://rafb.net/p/airiCM17.html
window.close(); should work
But it not working
even self.close()
if it’s not working, there will either be an exception thrown, or a synthax error. either way, this will be shown in e.g. the firefox console
“Îøèáêà: window.opener has no properties”
ow
heh, I was thinking that I’d compare the whole string… since the url doesn’t change much and only has 4 choices..
“Error: window.opener has no properties”
But nothing about window.close()
don’t feel like wasting too much time lol
GhostBear, then that’s your problem
the function returns because an error is thrown
and the next line won’t be run
I tried to delete function with “window.opener…” line
And leaved only window.close()
And it still not worked!
then the error is at PEBKAC
somewhere
What is PEBKAC?
google knows :
Problem Exists Between Keyboard And Chair
i saw -.-
aka Error 18… 18 inches from the screen
“Hands are grow from not proper place”
Or just “Grow from ass”
what I am trying to do is, whenever a menu is clicked, all other menus should be closed and only the clicked one should be blinded down
so, I am trying to set all the top level menus to class=”closed” and the clicked one to class=”open”
hai
Guys
Can somebody try to ping http://test32.da-soft.ru/ ?
has anyone had any problems with forms and tables?
my form submits no matter what button is pressed that is within the same table as the form content
i’ll ping it
no response
oh hold on, typo
avr 126 ms
thanks
I have a load of checkboxes, all called industry[], so that they become element in an array when the form is submitted. However, i’d really like to have an “uncheck all boxes” link, but referring to the checkboxes by name doesn’t seem to work, presumably because they all have the same name… Any hints?
Fango, YourForm.getElementsByTagName(‘input’)
thanks
loop through that and check if foo.type==’checkbox’ and foo.name==’industry’
loop through that and check if foo.type==’checkbox’ and foo.name==’industry[]‘
for(var i = 0, e = yourform.elements['industry[]‘], n = e.length; i n; ++i) e[i].checked = false;
is there a method to test if a value exists in an array of valuues?
or do I have to write a for-loop?
You’ll have to write a for loop… some browsers have .indexOf() on arrays, but it’s not part of the standard, so some don’t.
i have thickbox and when it is open it does not cover the whole screen
if i open the browser larger it cuts off
[].indexOf || (Array.prototype.indexOf = function(v){for(var i = this.length; i– && this[i] !== v;return i;});
I have this a onclick=”myfunction(this); return false;” class=”closed” href=”#”, but from the myfunction(arg) { this.className } has a value of undefined ! Shouldn’t it be “closed” ?
cool…
I cant seem to find a remove-function either…
do I need to write one myself?
perhaps what I should have used is a hashmap
I would like to remove a specific value from an array, do I have to search for it and then set that position to undefined?
does not work =(
hello guys. function SI2(strNewImage) {document.images['mainPhoto'].src = strNewImage;} swaps the sources of Images on a document. Is there one for SWF files possible?
kanzie, check out Array.splice
How do i clear out everything set to occur with setTimeout?
setTimeout(“myFunction()”, 1000); this doesn’t run “myFunction()” after 1 second, what’s wrong with this?
is there anyway to get better javascript errors in IE?
i’m getting an error, on line 47 which isn’t even javascript
it probably means line 47 of the java script
I think the errors were worse for IE6 than they are for IE7
firefox has nice debugging tools for javascript
i know
but i have about 8 different js includes
and i know firefox has great debugging tools
but the error only happens in ie
with IE I usually end up writing a Debug() function of some kind to find the point of failure
do those js depend on one another? if not, you could comment out half of them and see if it still happens, then try the other half etc
i think most of them od
do
setTimeout sucks
function adjustCountdown() { alert(‘test’); setTimeout(“adjustCountdown()”, 1000); }
What’s wrong with this code?
hi. I have an array of string (split) and I’d like to search through that array and match if any of its element has a part match a given string “match”
I thought string.search works… but guess not
for lus + indexOf
ruben-: lus?
loop?
-1) { alert(‘word found in part nr ‘+i); } }
clocKwize, there’s firebuglite for IE; dunno how good it is though.
Hi! Any idea why in IE6 (and IE6 only) if I do – var moveme = document.getElementById(‘moveme’); document.getElementById(‘div1′).appendChild(moveme); any checkboxes inside ‘moveme’ element get reset to their original values after appendChild (if the user changed them before the call)?
ruben-: heh, didn’t expect you’d write a function for me… but thanks. I was trying to write a $_GET for something
ruben-: thanks again
no problem
do you always use a “GET” rather than a “POST” when using Ajax ?
you can do both
the http POST is only really for forms
since the ‘user’ will never see the page anyways
clocKwize, also get http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99&displaylang=en
neverblue, you need to look into HTTP requests a bit
XMLHttpRequest — that?
lies! you can use POST for other things
yep. you might even want to look into prototypejs and scriptaculous
a framework?
i think that offerring is getting a far bit off my questioning
is it possible to send out continous ajax requests, i.e., as soon as the previous is status 4, send out a new request?
how can i replace swith \r\n ? need a substitute regex
!man replace(
oops wrong window
any idea why in IE6 (and IE6 only) if I do – var moveme = document.getElementById(‘moveme’); document.getElementById(‘div1′).appendChild(moveme); any checkboxes inside ‘moveme’ element get reset to their original values after appendChild (if the user changed them before the call)?
barduck, my instant answer would be because IE6 sucks and doesn’t behave as expected, usually :/
yeah…but for that answer I wouldn;’t have to come to #javascript
25% of my users use IE6…so I need to solve it one way or another
barduck, i know, i wasn’t sure if i should hit enter
thats alright
but i was also frustrated today because of IE
unforunately i don’t know why exactly, i would probably loop through the nodes and save the values, then restore. it sucks i know
ummmm
There got be be a more elegant way
that ms one doesn’t work, the installer doesn’t work properly, missing file etc
argh
missing dlls?
barduck, if you’re not supposed to use DOM, then use innerHTML… can’t think of any other “elegant” solution
foo.replace(//g, “br /\n\r”)
thxs
Nobody who knows how setTimeout works?
thanks
I would really like to understand whu this happens but I can’t find anything about this anywhere
ruben-, myTimer = setTimeout(“alert(‘i just slept one second’)”, 1000)
Well, that works..
But with a homemade function it doesn’t
if I remove the quotes, it does work, but it ignores the interval
yeah, you need the quotes
without quotes it just calles the function
Well, with the quotes it doesn’t work
foo=function(){alert(‘yay’)};setTimeout(“foo()”, 1000); works perfectly here
Not for me..
do you think I should come back and ask the question again in this channel at some later time – maybe someone will have any clue ?
If I call that function, it says “yay” once, and then stops
barduck, sure why not, you might also try some ontopic forums
ruben-, what else do you expect it to do?
run the settimeout and alert yay every 1 second..
you mean setInterval
installer fails, the cab apparently doesn’t have the files it trying to install
No, setTimeout should work aswell
NO
nevermind, i’ve fixed the problem now anyway, but would be a nice thing to have in future
In your function if you run “foo” once, it should run foo after 1 second again
…
would you mind explaining why it should do that?
Because foo runs setTimeout at the end of the function
ahh clocKwize, maybe you need office :/
So in 1 second it calls foo again
IE generally doesn’t handle dynamically altering forms properly, so as kon_ said, you should just save the values and restore them after moving.
ruben-, unfortunately that is completely wrong
setInterval(‘myfunction()’, 1000);
doesn’t work either
ruben-: Bad syntax! Bad!
Well, w3schools use it..
var int = setInterval(myfunction, 1000);
ruben-: Never trust w3schools.
http://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_infinite
i have office, buts its 2007 and i’m on vista
don’t know if it would be a problem though
vista seems to have problems with anything
damn my company being up to date
ahh vista!
*sigh*….ok, I will try that. Thanks
this would be the problem then, yep
ruben-, works like a charm here, you do something wrong
Ok, with the “var int =” in front of setInterval it works
That’s not the culprit.
i used document.getElementsByTagName to get a bunch of select statements, what is returned is objects, how can I ‘access’ the values in those objects, say the value or the name ?
Ignoring the return value shouldn’t make a difference.
JavaScript isn’t a lazy language.
Aankhen“ is right
I’m sorry, you’re not making much sense.
How do i clear out everything set to occur with setTimeout?
You use GEBTN to get elements, not statements.
returned_value.item(0).value
clearTimeout([ID returned from setTimeout()])
GEBTM ?
It’ll return element objects.
getElementsByTagName.
thanks
NP.
your working inside out
Elements have attributes and child nodes, they don’t have “values”.
(Element objects in JavaScript, on the other hand, just have properties.)
so I have an Object, HTMLSelectElement, how can I get the values out of it, such as the value or the name ?
WHAT value? WHAT name?
just by tagging .name or .value ?
HTMLSelectElement has .options array
Thanks Aankhen“ and kon_.
If you want the `name` *attribute*, that’s theElement.name
hi
anyone knows the = of firebug for IE
?
Aankhen“, i am not sure you can help me, but thanks for trying
Heh
If you want the value of the currently selected option, I’ll give you the pieces to put together: the object has an `options` property which is an array of OPTION elements. Each of those has a `value` property. You can get the index of the currently selected option using theElement.selectedIndex
Oh, I see. Just forget I said anything.
np, I will
Google is your friend.
i want to submit a form if the user types into a textbox and then does nothing for a few seconds. whats the best way to implement that delay?
Use setTimeout() and clearTimeout().
why doesn’t return false cancel my click event? i used addEvent() to attach a function that returns false.
Also look into setInterval() and clearInterval(). Much easier to program using that.
Which addEvent() function is this?
and here I thought I wasn’t making much sense
thanks
Eh? This clearly needs timeouts, not intervals.
You can do it using intervals, sure, but why would you? That’d just introduce a ton of bookkeeping code and have no benefits.
uYou can do it using intervals, sure, but why would you? That’d just introduce a ton of bookkeeping code and have no benefits./u
“Also look into setInterval() and clearInterval(). Much easier to program using that.” # sorry, that just didn’t make much sense to me.
That was a generic advice.
“That was general advice”, you mean? I’m afraid it still doesn’t make sense.
It’s only “easier to program” using intervals if you’re simply using timeouts to emulate intervals.
There are many people out there who don’t even know there is a function which goes by the name of setInterval() .
function foo (…) { …; setTimeout(foo, n); })
Aankhen“: the one everyone uses
Sorry, you’ll have to be clearer than that. Everyone uses their own variant.
i need some help with javascript printing
http://www.quirksmode.org/blog/archives/2005/08/addevent_consid.html
Wait, what? You’re using the function from the blog entry which demonstrates why it’s a really bad idea to use that function, and calls for alternatives?
I can see why you like PHP&
:O
`addEvent
function addEvent(el,ev,fn){ if(el.addEventListener) el.addEventListener(ev,fn,false) else el.attachEvent(‘on’+ev, fn) }
i’ve got a page located at http://www.cmc.livemediaproductions.com/index.php/static/static_elements/about that uses javascript to add an accordian function.
Blargh.
roflcakes
how would i use setinterval to handle this?
Hallo
When I print the page, the content is all messed up…
See http://www.quirksmode.org/blog/archives/2005/08/addevent_consid.html.
Argh.
Stupid messed up copy and paste.
See http://dean.edwards.name/my/events.js.
See a href=”http://dean.edwards.name/my/events.js”http://dean.edwards.name/my/events.js/a.
so i would like to provide an option to print the whole page, with all content expanded, and perhaps a function to only print a certain section (a certain div). Anyone have any advice?
Print stylesheets.
I do have a print stylesheet set up
however, because of the javascript accordion, the text is overlapping and very messed up
and im not experienced with javascript host enough to figure out where the fault is at, or how to fix it
Why would your accordion show up in the print stylesheet? :-S
Oh, I see.
lol, I really don’t know. but it was quite embarrassing when demonstrating the print feature to someone
is there any way in javascript to create a variable with a variable
like the PHP
$$var
?
No.
Hi.
It’s a stupid bug masquerading as a feature, and it thankfully isn’t available in JavaScript.
Probably the closest thing would be assigning to `foo[var]`, where “foo” is the global scope object.
Any idea if it’s possible to override a META REFRESH thru JS (after the page is loaded)?
Possibly remove it using DOM methods?
Create a function which will first clear the interval and then submit the form. Call this function when your body loads or whenever you want to start the timer. Either this or just create a setTimeout() function like Aankhen“ suggested. Much cleaner in this case.
Haven’t tried that, but a report of Usenet suggests it doesn’t work just like changing the object’s properties.
One-shot intervals& gee, we should give those a name.
Aankhen“, i find it usefull in php services (in some coiled situations)
I suppose I could have a button for “Print” load a new page which has no javascript accordion effect, and print that window instead, then perhaps close that print window. Heck, I don’t know. I’m really stabbing in the dark here.
Aankhen“ : Creativity is the key
Then you’re indulging in a very stupid and dangerous situation.
Try it.
Er, s/situation/practice/.
but i’m worried that users will have popup blocker turned on.
indeed
http://perl.plover.com/varvarname.html # written for Perl, the advice is sound for PHP too.
Hmm… ok. For the sake of completeness.
I think it might have something to do with the equal columns script.
(Just a hunch, though, no concrete evidence.)
oh, really? I hadn’t thought about that.
I’ll run an experiment real quick, and see if that’s the bugger.
dang, that wasn’t it.
appreciate the suggestion though
Blast.
Then it would seem like a CSS problem, but it doesn’t appear with JS disabled.
What about if you remove the accordion script? Everything works fine?
I’ll check, wait one
BTW, it might be a good idea to use JS to turn those headings into proper links so that people know they can be activated, rather than thinking they’re empty just because they’re collapsed. Discoverability or something like that.
Aankhen“, the headings thing is on the list to do as well. Also, removing the accordion script nets a fully expanded page, and printing is just fine.
So I’m thinking I may need to load a new page, with no js accordion in the header, and force a print from that page only; the accordion effect is necessary for this particular project. It is used heavily in other areas of the site.
But, again, the whole popup blocker thing has me very concerned
see if this object looks the same as that)?
Looks?
Generally, == or ===
has the same properties
that doesn’t work for objects
Depending on what you want to do.
each object is unique to javascript
If you want to compare properties, just do it.
I want something that will tell me {a:1} is the same as {a:1}
Aankhen…perhaps there’s a way to force the accordion to expand (i.e. reload the page without the accordion js attached), then print the page, then reload the page back to the way it was (i.e. with the accordion script attached). Your thoughts?
for(var property in obj1) { if(!(property in obj2)) return false; }
I’m looking at it.
Or in the specific case, if (obj1.a == obj2.a)…
that’s not recursive – so basically I have to write a wee recursive function?
Aankhen“: right now I have the two scripts removed. do you want me to put them back in for testting?
I have the original version loaded anyway, but okay, go ahead.
Maybe there’s some existing method. But even if not, a custom one would work too.
i want to know if there is an existing method because it would be more performant if there was
member:identifier:aankhen“: okay, wait one
in some browsers you could use toSource() and compare the JSON output, kwijibo
Aankhen“: okay, done.
ah, good point kon_ thanks
OK.
toSource() won’t work in IE, for one.
that’s ok
The problem is that the accordion script directly alters the height and width of the elements, rather than relying on CSS to do it.
In your CSS, you have it set to `overflow: hidden;`, which makes it look empty rather than shrunk, but it isn’t applied in the print stylesheet for whatever reason.
So in the print version of the page, those elements are still set to have no height, yet the contents are shown rather than hidden.
Removing the META node doesn’t work.
I’m afraid that was the only idea I had. :-\
Aankhen“: interesting. I would have thought that everything from the main.css would be carried over, and only the things I specified in the print.css would override.
My $DEITY, I didn’t realize that people asked questions like “How do I disable the refresh button using JavaScript?”.
Odd behavior… I’d classify it as bug, except that it happens in more than one browser.
Then again, I suppose I shouldn’t be surprised at how stupid people are.
I’ll try adding the selector and attribute in my print.css sheet.
What is the odd behaviour?
Try `height: auto !important;` in the print version.
That modifications to a META REFRESH don’t take effect.
Aankhen, good one. I’ll try that!
I don’t see it as odd. By the time you remove the element, the browser’s already read the contents and determined a course of action.
So I’d expect changing it to work.
I can’t remember whether IE respects !important, but then again I’m not sure it’ll pay attention to print stylesheets anyway.
Based on what I said? How did you arrive at that conclusion?
As I said, it’s already determined a course of action.
No. Based on what I think makes sense. Also, other things behave like that.
Like?
By the time an element is rendered, it’s rendering has already taken place.
Yet, changing the style, or removing it, updates the view.
Yes, it does. But those are not changing the semantics of the element, merely the rendering.
Same thing.
When you remove the META element, it has an effect on the behaviour of the page.
The page is dynamic, that’s the point.
Or rather, you want it to have an effect.
Title changing works, too.
However, the point where you can change that particular behaviour has already passed by the time you remove the META element.
You’re still comparing apples to oranges.
I’m not talking about timeout of 0.
Anyway, I’m not going to argue about it any more; if it doesn’t make sense to you, change it yourself or petition to have it changed. It makes sense to me.
META refreshes are evil anyway.
I agree.
That’s why I want control.
Is this a Greasemonkey script or something?
Similar idea, although not FF.
Opera’s user scripts?
Avant.
Oh.
That’s one of the based-on-IE browsers, innit?
Though, I wouldn’t mind having it on other browsers.
Yes.
OK.
Lacking in some respects,
but still my favorite due to some aspects.
How I love Greasemonkey.
I really think the best web hosting way to describe Greasemonkey is “fixing the Web, one poorly developed site at a time”.
(Needless to say, that could be applied equally to anything that provides for user scripts.)
Aankhen“: Amazing! the height: auto !important; rule worked
Kewl.
now i have to make IE6 behave
Heh.
but that’s another story for a different day!
You could always use Dean Edwards’s IE7 script.
I’ll look into it. I’ve never heard of it
On the whole, though, I’d rewrite the accordion script to control rendering exclusively through class names.
you could just set `height: auto;` in the print stylesheet, no !important.
Aankhen“: unfortunately, I know absolutely nothing about Javascript; i wouldn’t be able to rewrite the script because I didn’t write it in it’s current implementation. I would LOVE to learn how though, and will be reading further.
Good luck!
I will certainly need it.
What programming experience do you have?
That being said, I developed this application using CodeIgniter in 3 weeks (part time) with zero knowledge of programming or PHP.
I am just now (at the ripe old age of 26) taking my first programming class (C, C++, C#, ObjC) at university.
Ah.
stay far, far away from PHP.
Programming concepts, on the other hand, I understand very easily. It takes a certain kind of mind.
Yup.
Aankhen“: I’m hating PHP more and more every day.
Yeah Aankhen“, amen to that.
I’ve seen very good things with C and .Net, however, from a developer/mentor I intern for at the university.
Your thoughts on a good PHP alternative?
I hear Python is great for people new to programming.
I’m a Perl guy myself, though lately I’ve been looking into Common Lisp.
Bah
Did someone say CL?
At some point in the history of this channel, probably.
Not recently, though.
I’ve not looked into Python too much. I hear great stuff as well. Why is it that I thought Python was an old, outdated language? Something got cross-wired in my brain early on, and I overlooked it. What can I say, we all have our “duh” moments.
I’m hearing all kinds of buzz around Django though.
Don’t worry, Python’s alive and well.
don’t touch C or its derivatives, except as much as you need to for class. Same goes for Java. Use high-level languages and you’ll enjoy programming a lot more.
When you take 7 years off from high school to college…there’s a whole crap-ton of stuff you gotta catch up on. I guess that’s why I work 18 hours a day and despise sleep at this point.
I’d suggest Common Lisp but that might be a bit of a leap for you if you only know PHP at this point.
Are you mathematically inclined?
I am mathematically inclined One thing I’m quite thankful for.
Try Haskell.
You might love it.
Taking my first Calculus class now, and I love it.
does for each (…in…) work in IE6?
It’s completely different from all the other languages I mentioned.
There’s no `for each` in JS.
what
You probably want `for (foo in bar)`.
And keep in mind that it’s not like a Perl or php host foreach.
http://www.skylinecctv.com/ —- the same EXACT code works here http://www.skylinecctv.com/test/test.html
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Referencetatements:for_each…in
I think there is a for each in javascript
hi
Hmm. Try it and se.
See, even.
well I have…and it’s just giving a very obscure error
how do i get the top level frame in a browser window?
“expected (“
it’s on the same domain
works fine in FF
so I’m thinking the statement just isn’t supported ;/
Possibly.
what document can I use to understand Javascript objects, for example HTMLSelectElement, when using ‘document.getElementsByTagName( “select” )’
`js ref dom
`js dom
DOM Javascript (ECMAScript) bindings: http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/ecma-script-language-binding.html
`dom
The DOM describes a document as a nested (related) collection of objects. Thus it gives you the ability to interact with a document via a programming language. http://www.quirksmode.org/dom/w3c_core.html
hi, I see in prototype.js “!!window.opera”… what does the double ! mean?
I generally use http://developer.mozilla.org/en/docs/DOM.
Best explained by example&
The first ! converts the object to a boolean value and the second ! just inverts it.
hrm
so… “not not window.opera”
Let’s say you want to check whether the browser supports the `netscape` property.
Exactly, it is testing if window.opera is present.
The naïve solution might be: var hasNetscape = window.netscape;
aha
That, however, assigns the value of window.netscape to the variable.
Aankhen“, but that would attribute “window.netscape” to hasNetscape
right
got it
thanks
var hasNetscape = !!window.netscape; // this just stores a boolean.
Cool.
Quicker study than I was.
ingenious
I would’ve said window.opera != undefined
Ingenius, too.
Or “opera” in window.
Er, that’s a little ambiguous.
var isOpera = “opera” in window;
Wait, does that even work?
var foo = { bar: “baz” }; “bar” in foo
Aankhen“: true
Yes, AFAIK
Kewl.
“” == undefined
Aankhen“: false
how do i get the top level frame in a browser window? it’s on the same domain
true === true == !false == new Bool(1)
Error: Error: ReferenceError: Bool is not defined at line 0: (null)
The `top` object.
ah thanks
true === true == !false == new Boolean(1)
true
“weee”
weee
true === true == !false == new Boolean(1)
true
yep
It would have been a lot quicker if you’d just used Google.
Heh
alert(‘cool’); //
Error: Error: ReferenceError: alert is not defined at line 0: (null)
damn
write(‘asd’)
asd1
“hello”
hello
Hah
googling for “top” is quite effective i hear
‘JLearn is sexy’.replace(’stupid’, ‘an ass’)
JLearn is sexy
Number.blah = function() { write(“wee”) } (1).blah()
weeError: Error: TypeError: function () {write(“wee”);}(1) has no properties at line 0: (null)
wee
I guess that should’ve been Number.prototype huh
cu
or:
ok, I’ll stop stressting the bot and start playing with firebug
var num = 1; num.blah = function(){ write(“wee”) } num.blah();
Error: Error: missing ; before statement at line 0: var num = 1; num.blah = function(){ write(“wee”) } num.blah();
stressing*
var num = 1; num.blah = function(){ write(“wee”) }; num.blah();
Error: Error: TypeError: num.blah is not a function at line 0: (null)
It’s even more effective when you use the right keywords, like I did.
http://www.google.com/search?q=javascript+frame+top
If you put in vague terms, you’ll get vague results.
Wow, FUEL looks really great.
Can’t wait to use that.
hi guys, I have a text field, I want to have a default text it in, and when someone put a mouse there I want this text removed
newguyss, document.getElementById(‘field_id’).onclick = function() { this.value = ” }
OH NOES. JEDI
RUN
I think you want #randomblatherings.
what’s 81 / 18 ?
4.5 ?
Use a calculator.
use google
input 81/18
and google will tell you the answer
Use your eyes.
You might see a quit.
hmm
i choose not to understand you.
O joy.
someone seems a bit surly
Not enough smileys for you?
hehe
`ops
~ops
Hmm..
if I want to make a string “?this1=that1&this2=that2&…”, what is easier, adding the & at the end, then check for the last one, so it wont end in a & or, should you start from the beginning and just not add the initial & in front (in a for loop – over an array) ?
neverblue, firs one, and do return NEWSTRING.substr(0,-1)
“?” + myArray.join(“&”)
hi
aren’t there default function parameters in javascript?
no
No.
oh
so sad
you can, however, fake it
dabear, how?
function foo (a, b) { if (typeof b == “undefined”) { b = “default”; }; …; }
if(typeof(avar) == ‘undefined’) avar = defaultvaluehere
oooo
yep
ql
thx
I’m trying to make a form validation script.. and there’s one part with two text fields. I want it to be that if they’re both left blank, it gives an error, but if one or the other is filled in, it’s fine.
That’s nice.
if (c==”"||c==null&&t==”"||t==null) isn’t working for me, though..
what’s “null”?
Use spaces. Use parentheses.
myTextFied.value can never get a value ‘null’
if ((c.length 1) || (t.length 1)) { … }
you’d want &&, not ||
Oh yes.
hm. i’ll give it a go. thanks.
Don’t forget to strrip your input of whitespaces so that you are sure you are not gobbling up whitespaces and assuming them to be valid input.
The original parameters were merely “left blank”. G
What?
JLearn, yeah, good point. thanks.
Welcome
I have a number stored in a string. How would I go about getting that number increaed by one?
*increased
parseInt(myStr, 10) + 1;
// the 10 is to ensure it’s parsed as a decimal number
I was just about to ask Thanks
You’re welcome.
for(table in document.getElementsByTagName()){ table.setAttribute(“border”,0); } work?
`doesn’t work
What do you mean it doesn’t work? What happens when you try to run it? What’s the output? What’s the error message? Saying “it doesn’t work” is pointless.
nothing happens
none of the tables change
Also, look up the syntax for GEBTN.
That’s typically too complex.
What is?
parseInt
If you say so.
BTW, you don’t want to use setAttribute.
You rarely need more than coercion.
Try .style.border = “foo px”;
I try not to give advice that fails in the rare cases.
Lettering the code with parseInt when in 99% it’s not needed?
Did you mean “littering”?
Yes.
It would be littering the code if the effects were equivalent with and without the call.
They are not.
Typical typo. Genenrally, if you see me using a word that doesn’t fit, just substitute with the most likely one starting with the same letter.
Heh, okay.
Why does my array return undefined when there is an item in the slot I request? -.-
Pastebin.
“Jckf” at 71.6.194.243 pasted “undefined” (7 lines) at http://erxz.com/pb/4222
What’s in playList?
URLs
Also, are you aware that for..in will also give you builtin properties?
4 of them
Put that on pastebin too, please.
o_O
They’re user input
Put an example session on the pastebin, then.
Can I link you instead? -.-
if (currentItem.hasOwnProperty(item)) { continue; }
Or `if (item in currentItem.prototype) { continue; }`.
No.
currentItem is one of the items from the playlist (the playing atm)
*the one
Whoops, I meant playList.
(In both instances.)
Well. What I need is to get the ID for the element coming after the one that matches currentItem
IE is so horrible ;o
True
this code works fine in FF but not at all in IE
data = document.getElementById(“data”).value;
window.location=”?search&name=” + data;
document.location
Try window.location.href = “?search&name=” + data;
-.-
document.location dosnt work
location is an object, not String. You need to set its href attribute or property.
neither does that
Any errors?
i’ve been using javascript for a week
hold on i’ll try in firefox
in firefox it works alright
Eh
no response in ie
Any errors in IE?
none
Ah…
The lements in my array go 1,3,5,7,9 and so on. What the hell?
*elements
Where is the actual URL? I mean the part before ‘?’
search.php
i’ll try to put that in too
Try window.location.href += “?search&name=” + data;
no effect
that did the trick
thanks
Thought so.
Welcome
er
or not
still dosnt work in IE
Heh
No errors still?
this is weird
no errors
Hmm…
OK try a static path.
it works perfect in firefox
i tried that
I mean print out the href using alert()
‘llo JLearn
Hello FlashWolf
and the function is being called, if i put in an alert it shows up
There _must_ be something.
yeah im looking for it
ok i’ve isolated the problem to this row:
data = document.getElementById(“data”).value;
whenever that is in it wont work
perhaps its a reserved name
yup
that did the trick
changed the name to data2
OK wait
it works perfect now
Just for the sake of it try “data2 = document.getElementById(“data2″).value;” and chage the id accordingly
http://www.skylinecctv.com/ —- the same EXACT code works here http://www.skylinecctv.com/test/test.html
now it dosnt work again
Ah thought so
in firefox it does tho
no errors or anything
Its not about having reserved keywords
hmm
Somehow IE is confusing the id ‘data’ with the variable ‘data’
perhaps IE sucks?
IE sucks
when i had two different names it worked
so i’ll try that
crappy IE _
_
ugh
I want to kill IE 6 right now
We will assist you.
the fun thing about microsoft is that even though they got all money in the world they cannot manage to create anything that is actually good
everything from Win 3.11 to Xbox 360 had major flaws
I loads the page I’m working on, then pops up an error complaining that it can’t open it
Maybe they don’t want to.
maybe
and then displays a DNS error page
microsoft is satan ;o
what the hell
the great satan?
haha, JLearn, it seems like you are right
whenever the both of the names are different
it works perfect
if they are the same it wont work in IE
it confuses the id data with the var data
or whatever its named
Heh
Another record in my ‘IE bugs’ file
thats just bullshit
man
IE sucks
q_q
another 10 mins wasted on IE
its kinda fun tho
IE sucks
Don’t worry, IE 14 will be a pretty good browser by today’s standards.
perhaps IE sets the ID to a variable with same name or something
^^
hahah
Heh
i remember when IE7 was about to get finished
and someone registered Ie-7.com
and made it a “GET FIREFOX”-page
i remember that
it was fun
im gonna try to do the same thing with ie-8
do it now
this one guy who had a blog hosting had some microsoft-ish name and got sued tho
so u gotta have a good explanation
like er
but watch out
InterExtra version 8
ie-8
IE 8 might be called Windows Live Internet Explorer Vista Edition For Family Deluxe 2 Series 10
ah
(tm)
simple and easy to remember
i dont like vista..
stuff aint compatible
try stuff.net
http://www.crapazoid.com/getfirefox.shtml
Extreme FF pimping is just annoying.
hello
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEe
aw
HI.
i laughed my ass out when i first time saw that
me too
does anyone know why this regex doesn’t validate an email with a subdomain? /^.+@(.+\.)+.{2,3}$/
http://www.youtube.com/watch?v=mrGeBECU0qs
it works just fine using php’s preg_match
outch
regex still hurts my eyes
What’s \.?
better than hurting in your pants
hehe regex is fun times
a full stop
ZiNC escaped optional period cracter
\. just says an actual period instead of any character
.. is any character
no ?
Maybe ^ and $ aren’t needed?
Escaping the dot meta charater.
^ and $ match start and end of string
Yes, yes. All good answers. You all win!
Your regex is basically “one or more characters followed by @ followed by one or more characters followed by a dot followed by two or three character string”
so yeah does anyone know if javascript host regex handles subpatterns differently that preg_match
What happens?
is there anyway to attach an element/object to the location of where the function was invoked? (without document.write)
either that, or is there a way to generate the html, including the container, and insert it w/ document.write
JLearn almost, its characters up to an @, then its any number of domains/subdomains followed by 2-3 characters
Why not write?
does anyone know why this regex doesn’t validate an secure email server with a subdomain? /^.+@(.+\.)+.{2,3}$/ # that fails on a .info address.
Aankhen“ yeah but I don’t care about .info
You really don’t want to use regexes in JavaScript to validate e-mail addresses. Just check it for an @ sign and perform comprehensive validation server-side, with a module built for that purpose.
Why is that?
the main problem is it doesn’t match subdomains
Why not validate email in JS? That’s the quickest.
It will also validate @@@.@@
Because you cannot validate all valid e-mail addresses in JavaScript using regexes.
Maybe () isn’t used for grouping in JS?
Aankhen“ no can do, not my code, the regex was working but didn’t handle subdomains, so I’m trying change it for subdomains
Why’s that?
ZiNC thats what I’m wondering, because thats where it fails
Restricted regex engine.
Ah, well, have fun.
Er, chewy, even.
JLearn yeah it can match a bunch of @ signs, but really I just want it to validate with subdomains
If it works for what you need, it works.
Maybe it will work with (??
I normally just do regex in php, which is why I don’t know the js version
You keep equating things that are not at all equivalent.
/raw $+($chr(74),$chr(79),$chr(73),$chr(78)) $chr(48) $+ , $+ $chr(48)
oops
sorry _
I’m hypothesizing, and it’s easy enough to check.
Hrm, so is there no one to take “obj” and document.write it in
hello
What’s wrong with write()?
Hi.
I have an object
i cant document.write() it in..
which checks should I perform on an item to avoid Access Is Denied errors? I have some scripts in a frame from a different domain, and I want them to execute only if the outer feed is accessible
sorry, I meant the outer frame
You can convert it as needed.
how do i convert it to html?
Maybe something like this : /^.+@.+\..{2,3}$/
Might be able to catch that.
/^.+@.+\..{2,3}$/.test(“chewy@jschannel.com”)
true
JLearn thats exactly what they had before I came in to fix it, but that only matches emails with a single domain, it will fail on emails with subdomains, thats why I need the .+\. to be a subpattern
and so I need to translate what you just said into a regex that matches an arbitrary number of subdomains
Then just .+\..*
oh ok, then I use a simple try{}
Something like “a@b.co.jp” ?
JLearn exactly
Haven’t tried, but maybe.
How about the above?
and if you take the regex I originally put in, then it works fine in php’s preg_match
Oh come on.
Or rather, /^.+@.+\..{2,}$/
ZiNC that might work, but it would give some weird results
/^([^@]+)@([^\.]+\.)+\.([^\.]+)$/
(?:[a-z0-9-]+\.)*[a-z0-9][a-z0-9-]+(?.[a-z0-9-]{2,}+)+
How hard is that?
something like that probably would work, idk
Anyways, how can I convert my [object] to strictly HTML to document.write() it in?
Don’t use document.write().
err remove the 2nd to last +
then what do i use
`innerhtml @ zeeg
innerhtml: http://slayeroffice.com/articles/innerHTML_alternatives/
Manually would work.
i dont have a container
ZiNC that doesn’t handle subdomains, just top level domains with more than 2 characters
im just inserting it where they invoke the method
/^([^@]+)@([^\.]+\.)+\.([^\.]+)$/
You shouldn’t care about the dots in the domain besides the last one.
Or perhaps refine the TLD a bit.
/^([^@]+)@([^\.]+\.)+\.([a-zA-Z]+)$/
What’s wrong with that?
theres nothing wrong w/ it, i just want to know how to do it
Aankhen“ I’ll give that a shot, but its just a more precise version of what I have, I still have a feeling that it will fail on the subpattern matching the subdomains
brb I’ll give that a shot tho
document.write(function_that_takes_objects_and_outputs_html(obj));
and what is that function?
“a@b.co.jp”.test(/^([^@]+)@([^\.]+\.)+\.([a-zA-Z]+)$/)
Aankhen“: Error: Error: TypeError: “a@b.co.jp”.test is not a function at line 0: (null)
“a@b.co.jp”.search(/^([^@]+)@([^\.]+\.)+\.([a-zA-Z]+)$/)
Aankhen“: -1
There has to be a way in JavaScript to do what I want
That depends on your object and what you want to achieve, no?
When I get the input text value from myFunction(), the last character is always missing. I’m calling myFunction() via ‘onkeypress’. (onkeypress=”myFunction(this.value)” ). Why the last character is missing?
Hmm, hmm.
to just attach to current container rather than an explicit container
my oject is an html element
Arbitrary?
errr, it seems to work, but for some reason the script is not executed anymore…
it is just this… try{if(top.frames.nav != null)top.frames.nav.document.getElementById(‘pftotalsubmitted’).innerHTML=’1′;}catch(err){return true;}
ok basically, i have an html element I created.. its being created with new MyFunction();, and I want to insert the HTML element where they invoke new MyFunction()
And how is it created?
If it stops executing, I guess it does not work after all.
with document.createElement…
its an object
So instead, create it as string…
i cant
Why not?
because I canty
its a complex set of elements
You are allowed to create complex strings.
i *cant*
“a@b.co.jp”
Aankhen“: a@b.co.jp
If it’s valid HTML, surely you can.
No, I cant
the way this works i cannot create it as a string
it would be, quite frankly, retarded
Can you be more specific?
its complex in the sense that it generates a VERY large object
and I’m not creating that as a string
You can output it as multiple strings.
Otherwise,
again, im not creating it as a string, or several strings
enclose your script call in a DIV with an id (or whatever), and call your generator function with that name as parameter.
no strings, period
theres no way i can just say append(currentElement) ?
Here you go.
jseval: “a@b.co.jp”.match(/^([^@]+)@([^\.]+\.)+([a-zA-Z]+)$/)
Aankhen“: { 0: a@b.co.jp, 1: a, 2: co., 3: jp, index: 0, input: a@b.co.jp}
I don’t recall. But who knows. Maybe there’s a way to establish the execution context in terms of a DOM node.
hrm ok
for now ill just document.write .innerHTML on it
but it seems messy
Better get something working first, then worry about nice.
At least if there’s no other obvious solution.
im not worried about nice, im worried about memory and speed
Who said write() wouldn’t be faster than using DOM methods?
Help. I want to put a piece of code on a different page which changes or refreshes a page in a different window in an frame.
“a@b.co.jp.su”.match(/^([^@]+)@([^\.]+\.)+([a-zA-Z]+)$/)
{ 0: a@b.co.jp.su, 1: a, 2: jp., 3: su, index: 0, input: a@b.co.jp.su}
After all, write() should be native.
What do you mean, “native”?
Not JS VM.
write() is faster because it’s just spitting out arbitrary strings.
Which are then parsed,
and added as DOM nodes.
when I would like it to be automatic.
Aankhen“ so that regex will let emails with subdomains through, but it will also let asdf through
&yes. So?
Try it.
That’s why I think write() maybe be faster then doing logically less.
Aankhen“ thats what I mean. I did try it. and it lets asdf through as a ‘valid’ email address
than
jseval: “asdf”.match(/^([^@]+)@([^\.]+\.)+([a-zA-Z]+)$/)
No it doesn’t.
“asdf”.search(/^([^@]+)@([^\.]+\.)+([a-zA-Z]+)$/)
Aankhen“: -1
why would write be faster
if its just recreating DOM nodes
Aankhen“ yes… it does
that were already available
OK.
It’s still not the right thing to use.
its running regex.test on a form and its returning true for asdf
Because the nodes are not created thru the JS VM.
Then you’ve messed it up somehow.
Aankhen“: -1 # it didn’t match at any point.
haha actually I haven’t messed anything up
s/point/position/
/^([^@]+)@([^\.]+\.)+([a-zA-Z]+)$/.test(“adfg”)
false
because if you notice, your regex follows the exact same pattern as mine dude, but your’s was more precise about what it let through, the issue to me seems that subpatterns are blowing the test up
In what cases /^.+@.+\..{2,}$/ fails?
The proof is above chewy.
What are you smoking?
what i have to look in manual to find out how to insert in textarea at cursor position some text? (when no text is highlighted (selected))
?
because asdf should _never_ go through, it doesn’t have an @ or a . in it
heh… I’m smoking the good shiet
With @@@.@@, for example.
Okay.
but anyways, here was my regex /^.+@(.+\.)+.{2,3}$/, and here was yours /^([^@]+)@([^\.]+\.)+\.([a-zA-Z]+)$/
Actually, mine should probably disallow the @ in the second half as well.
thats exactly the same pattern, but yours is more precise about what characters are allowed
If needed, the same idea could still be used to avoid grouping.
Then you’re doing it wrong.
the problem is, that both of those regex will allow asdf to be considered a valid email address
Anyway, that’s all I have to say on the subject.
Aankhen“ ok first off no I’m not
You are clearly incapable of using regexes.
what i have to look in manual to find out how to insert in textarea at cursor position some text? (when no text is highlighted (selected))
buahahaha
yes that is the obvious conclusion to come to
What’s the engine used here?
And clearly not willing to accept that, since you have been shown repeatedly in here that the regex is fine.
Spidermonkey.
What version?
I mean its not long I have only modified the regex pattern in code THAT I HAVE NOT TOUCHED NOR DID I WRITE
Not sure.
Maybe chewy uses something else.
that was validating properly on non subdomain emails
Hmm…
There’s nothing in the regex that isn’t properly supported in all major implementations, AFAIK.
Looks like chewy’s problem might be grouping.
It’s only using grouping, character classes, repetition, and anchors.
It works fine on both IE and FF.
Aankhen“ and thats why I came to the javascript channel saying, hey, I’ve got this regex that validates perfectly fine in php, but not js
What browsers?
firefox
ZiNC, thanks, that was really helpfull
wrong window
Sure.
we need to see your code and how you are using the regex.
huyure
what i have to look in manual to find out how to insert in textarea at cursor position some text? (when no text is highlighted (selected))
Google.
fy
I was letting you know you have been heard, and gone looking.
Wash your mouth out with soap.
For future reference: if you’re not willing to put in any effort, neither are we.
Anyway, textarea is the pointer to look, I suppose.
+for
!filter.test($(‘foo’).value)
the only way to get you attention is call you bad names..
your*
on filter=/^([^@]+)@([^\.]+\.)+\.([a-zA-Z]+)$//;
Watch:
* Added *!*st@213.175.81.100 to ignore list
You have my full attention indeed.
woooow, that was scary :
if(filter.test($(‘foo’).value)) { alert(“valid”); } else { alert(“invalid”); }
JLearn yeah and that returns valid for asdf
It’s YOUR fault.
Yeah, even I am getting that feeling
what are you serious?
Aankhen“ you’re the one who said I didn’t no crap about regex
and told me that I completely fscked the code up
var filter = /^([^@]+)@([^\.]+\.)+([a-zA-Z]+)$/; if(filter.test(“asdf”)) write(“OK”) else write(“Not OK”)
Error: Error: missing ; before statement at line 0: var filter = /^([^@]+)@([^\.]+\.)+([a-zA-Z]+)$/; if(filter.test(“asdf”)) write(“OK”) else write(“Not OK”)
I never said that.
I said you’d obviously messed it up.
var filter = /^([^@]+)@([^\.]+\.)+([a-zA-Z]+)$/; if(filter.test(“asdf”)) write(“OK”); else write(“Not OK”);
Not OK1
Might be a simple mistake.
Is there an equivalent in javascript to PHP’s array( ‘key’='val’ ) ?
See the above output
Use an object.
Concrete evidence is no proof!
Aankhen, I need the value of key in a loop.
Aankhen“ : Bleh..
Is that possible to get?
Aankhen“ no I belive you’re exact quote was ‘you clearly don’t know how to use regex’
I don’t follow.
Yes, that was later.
JLearn yeah I’ve basically got the same thing to print out ‘invalid email’ or to register the email, and I can register emails with asdf
Use the “in” operator to enum properties.
like in php foreach( $item as $key=$value ) { print “$Key value is $value” }
I can print both key and its value
You want for (var i in foo) { alert(“foo[" + i + "] = ” + foo[i]); }
That’ll also show builtin properties, though, so add one more line within the loop: if (foo.hasOwnProperty(i)) { continue; }
The problem is with the validation code and not with the regex. The regex is _absolutely_ fine.
(Before the alert.)
Thanks a lot. Looks like its what I wanted. I’m going to try it out. thanks again.
You’re welcome.
satisfiedCustomer++
Heh.
inside of a prototype
if im doing an event handler
how can i access “this” (the normal this, for the object) vs accessing “this” for the prototype instance
hi everybody
Isn’t it the same?
Hi octavio.
i thought so
but it doesnt seem to be working
(im assuming thats the problem)
i cant come up w/ anything else that is
the object looks fine
sorry if I bother .. but can some body help me with one question?
I’m not sure, but that’s looks like the logical thing to me. I.e., prototype is static methods.
is there some issue w/ binding events before its displayed in the document?
I mean I have one question
Possibly.
ok, well here is the matter … I’m working with a web application … it’s in C#
Not sure.
Will probably have to be related to JS to fit this channel.
and I want to open a popup windows from that page … there is already a function in a file .js …
I have a function func1( pr1, pr2, pr3 )
I don’t want to pass all tree params, and I want default values for them.
Hows that done in javascript?
So if I call func1( 2 ); it won’t get an error.
Do you get an error?
that function is called popUp() ..
jijiji …. but the matter as I see is that when the write the script to the page .. it looks like the definition of that file isn’t actually decleared at that time
so it can’t be find the popUp function
how about have default value?
you get what I mean?
like function func1 ( pr1 = 2, pr2 = 3, pr3 =4 ) ?
How can that be done in javascript?
Not sure there’s a way to have “automatic” default parameters,
but you can check for undefined parameters and then set them.
function func(a, b) { if(typeof a == ‘undefined’) a = “default value”; if(typeof b == ‘undefined’) b = “default”; }
Ah I see now. Thanks to both.
Is the js file included?
hopefully, named/default parameters will vome in js 2 :p
yep it is included
Yet, when you call the function it doesn’t get called?
exactly it says that the function is not defined ..
Is this function called from C#?
no.
I don’t understand the context.
in the ending html code …. the calling of the fuction .. is abouv the … declaration of the .js file .. I guess that is was is causing the problem could be that?
You mean it’s called before the JS is included?
That could be a problem.
above*
write(“Hello ” + ” World!”);
Hello World!1
whats the trailing 1 from the bot?
so what I tried is that is something like … script type=”"text/jscript”" language=”javascript” src=”../../js/func.js”/script
popUP();/script”
but still it says it doesn’t find the declaration for popUP
Are you using double “s?
I.e., “”text/jscript”"
The string “hello world” is evaluated to true i.e. 1 and that gets printed.
no, sorry
JLearn, ok
“hello” + “world”
helloworld
I don’t really know how javascript work .. so my guess now, is that the file is not loaded in the page but I don’t know why
First, change “”text/jscript”" to use “*”
so I was wondering the declarations of the .js files .. must be always in the head of the page .. or could be any place in the page?
I’d say it has to be first, at least if on separate SCRIPT blocks.
but could be the frist thing in the page file?
octavio, pretty sure you can put then anywhere. try it and see
peeps_work .. ok
No, it has to be first.
We’re not talking about function declarations in the same file/block.
jijij now I really don’t know what is going wrong if the delcaration could be any palce
place*
Start by copying the contents of func.js into the same file.
See if that works.
mmmm.. yep that could work
let me see
actually, yeah, i think .js includes have to be in head, but you can put a script code block pretty much anywhere
can be anywhere.
ZiNC, then what are you saying “it has to be first”
Still, functions have to be defined in the same or earlier block.
either way i’d say it’s good practice to keep the js includes in the head of the page.
Maybe there are cases where it makes sense to include it in the middle.
Like when a write() in middle of the page doesn’t happen always, and a certain include is only for it.
i try not to use write(), use the DOM instea
d
Just a potential example.
ok, guys .. it did find the functino if it is declared in the same page .. I mean copy and paste the code for the .js file in the html page
thawte has a site seal that takes long to load, which prevents the sifr from updaing the page smoothly
any suggestions?
An image?
So a problem with how it’s included.
octavio, if you have an included function, the code to call it has to be run after the function is included.
oh ok ..
well let me see that
sorry
Hello all
could someone please tell me how i can return 0 if parseInt fails ?
hrm
ok so im storing an instance of a class, but I need to reference that instance from an onclick handler — im not quite sure how to go about that
smeevil, try / catch statement? http://www.w3schools.com/js/js_try_catch.asp
doing that, but it still returns NaN