tag:blogger.com,1999:blog-5777290109635933739.post3372340077234336039..comments2023-10-30T14:37:32.876+05:30Comments on IdeaMonk: instr is indexOf in javascriptAbhishek Mishrahttp://www.blogger.com/profile/12093818682511281896noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-5777290109635933739.post-33795401324206226562011-10-03T13:55:47.609+05:302011-10-03T13:55:47.609+05:30Here's what's happening, document.getEleme...Here's what's happening, document.getElementById would return you a DOM node, if exists. Which would be of the type Object in javascript. Whereas indexOf, in javascript, exists in the prototype of String types. Which is why it wouldn't work for an object.<br /><br />Now, I suppose you're trying to make indexOf work on contents of an element, whose id is known. If that's the Abhishek Mishrahttps://www.blogger.com/profile/12093818682511281896noreply@blogger.comtag:blogger.com,1999:blog-5777290109635933739.post-65867400637391622522011-10-03T01:59:08.197+05:302011-10-03T01:59:08.197+05:30Hey, I try to change
var foo="ideamonk";...Hey, I try to change<br />var foo="ideamonk";<br />to<br />var foo=document.getElementById('myText');<br />but it kills the script, why's that?Weilunhttps://www.blogger.com/profile/13110371969693386095noreply@blogger.comtag:blogger.com,1999:blog-5777290109635933739.post-89959406600596773852011-09-10T15:50:15.055+05:302011-09-10T15:50:15.055+05:30Cheers!Cheers!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5777290109635933739.post-9206713689064460382009-03-13T17:48:00.000+05:302009-03-13T17:48:00.000+05:30@Prairie: woops... thanks a lot... I've changed th...@Prairie: woops... thanks a lot... I've changed the code now. That really slipped my eyes...<BR/><BR/># document.writeln (foo.indexOf('idea")); <BR/><BR/>becomes<BR/><BR/># document.writeln (foo.indexOf("idea"));Abhishek Mishrahttps://www.blogger.com/profile/12093818682511281896noreply@blogger.comtag:blogger.com,1999:blog-5777290109635933739.post-32098657231271780722009-03-13T17:20:00.000+05:302009-03-13T17:20:00.000+05:30It looks like you are you mixing quotation marks a...It looks like you are you mixing quotation marks around your search term. Is that right?KansasCoderhttps://www.blogger.com/profile/10373918853853295105noreply@blogger.comtag:blogger.com,1999:blog-5777290109635933739.post-63443488527739873962008-11-11T17:37:00.000+05:302008-11-11T17:37:00.000+05:30Hey thanks, this was really useful.Hey thanks, this was really useful.Anonymousnoreply@blogger.com