Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #26630
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2015-01-20 02:26 -0800 |
| References | (2 earlier) <m9iue0$bah$1@speranza.aioe.org> <6abe327d-c487-4e03-8a6f-f7f65ebc8bb0@googlegroups.com> <14epavonqlnzl.2wklfi1o8grp.dlg@40tude.net> <0b11760e-aae1-4429-bc43-1b2559d81532@googlegroups.com> <1citvdfso3dg5$.jcaqtpmc522l.dlg@40tude.net> |
| Message-ID | <b5084f22-bf79-4542-8242-8efb59ea4cbe@googlegroups.com> (permalink) |
| Subject | Re: quick question: how to dynamically an image source file? |
| From | justaguy <lichunshen84@gmail.com> |
On Monday, January 19, 2015 at 7:31:50 PM UTC-5, JJ wrote:
> On Mon, 19 Jan 2015 14:24:30 -0800 (PST), justaguy wrote:
> > Ok, and since I need to find if var b has been defined, so, I rewrote the code below (thought its syntax is correct).
> >
> > if ("undefined" == typeof b) {
> > console.log("b is not defined");
> > b = 0;
> > }
> > else {
> > alert ('b is defined');
> > }
> >
> > Hence, in either case I would receive debugging info either via console (firebug is turned on) or via browser itself. However, none.
> > Which seems to suggest that the following code to run the js function has not been executed.
> > // just run the function
> > f1();
>
> It's still not clear where exactly the f1() function is called. Chances are
> that you have error elsewhere in the code that isn't mentioned - before that
> f1() function call.
>
> > I thought, upon this page(a div) load, the js code is also processed but...
> > and in case some other js code inside this js function causing problem, I
> > also tried to place an alert at the start of this js function, the alert
> > didn't alert. So, it seems that this js function is simply not called.
> > Question, why not?
>
> What DIV? You did enclose you JavaScript code with SCRIPT tags, or did you
> simply put the JavaScript code inside that DIV tags?
Hi,
I've solved this problem by setting a default value for global var b, that is, b = 0 outside any function, then, at the start of another function, I reset its value to 1. That is, without value evaluation of this var.
Now, I'm stumbled by the following situation.
HTML code in the same page:
<a href="" onclick="if (b === 0){resizeL()}else{shrink()}">
<img src="exp.png" id="tn" style="width:22px; height:32px">
</a>
Result upon click ->
load a function lighting fast and return to its original state or cancel it.
<input type="button" value="<->" onclick="if (b === 0){resizeL()}else{shrink()}" id="nav" style="width:22px; height:32px">
Result upon click ->
As expected.
fyi,
(1)
resizeL() {
...
document.getElementById('nav').value = '-><-';
...
}
(2)
I've tested it using both Firefox (recent version) and Chrome (also recent version).
Why so?
Thanks.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-18 19:39 -0800
Re: quick question: how to dynamically an image source file? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-19 11:20 +0100
Re: quick question: how to dynamically an image source file? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-01-19 10:48 -0200
Re: quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-19 07:52 -0800
Re: quick question: how to dynamically an image source file? JJ <jj4public@vfemail.net> - 2015-01-20 02:47 +0700
Re: quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-19 14:24 -0800
Re: quick question: how to dynamically an image source file? JJ <jj4public@vfemail.net> - 2015-01-20 07:31 +0700
Re: quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-20 02:26 -0800
Re: quick question: how to dynamically an image source file? Tim Streater <timstreater@greenbee.net> - 2015-01-20 12:08 +0000
Re: quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-20 12:20 -0800
Re: quick question: how to dynamically an image source file? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-20 14:06 +0100
Re: quick question: how to dynamically an image source file? Tim Streater <timstreater@greenbee.net> - 2015-01-20 14:52 +0000
Re: quick question: how to dynamically an image source file? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-20 20:47 +0100
Re: quick question: how to dynamically an image source file? Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-19 21:15 +0000
Re: quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-19 14:25 -0800
csiph-web