473,322 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem of duplicate function names: When 2 same type of JS loaded in 1 Page

I am stuck with strange JS issue

My product gives user to show some images(which track mouseover) on
page by embedding script like
<script src=http://domain.com/GetDynamicJS?domagic=1>
</script>

Now user is embedding more than of the above and when user mouse over's
the image output of first1 than function getting called is script
loaded in last ... thus error, as that script don't have the relevant
data for it ...
Any solution for ?
Following possible solutions look feasible to me?
1) Somehow I get a static variable and all the JS loaded from my domain
will keep data in that static variable, how to implement it, im not
sure :)
2) This is crude, but how about I dynamically give method names of
events in script such that there are no duplicate function names, but
this will again bring lot of other complexity and might need usuage of
eval which is evil and I'll look some option for not using it rather
TIA

Apr 23 '06 #1
2 1536
he**********@gmail.com said the following on 4/23/2006 12:16 AM:
I am stuck with strange JS issue

My product gives user to show some images(which track mouseover) on
page by embedding script like
<script src=http://domain.com/GetDynamicJS?domagic=1>
</script>
Your script tag isn't close to any form of valid HTML but ok.
Now user is embedding more than of the above and when user mouse over's
the image output of first1 than function getting called is script
loaded in last ... thus error, as that script don't have the relevant
data for it ...
"more than of the above"? Are they including more than one copy or more
scripts than just yours?
Any solution for ?
Following possible solutions look feasible to me?
1) Somehow I get a static variable and all the JS loaded from my domain
will keep data in that static variable, how to implement it, im not
sure :)
The response to that depends on the answer to my question above.
2) This is crude, but how about I dynamically give method names of
events in script such that there are no duplicate function names, but
this will again bring lot of other complexity and might need usuage of
eval which is evil and I'll look some option for not using it rather


eval is evil indeed but eval is not needed to access dynamically named
functions.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 23 '06 #2
he**********@gmail.com wrote:
My product gives user to show some images(which track mouseover) on
page by embedding script like
<script src=http://domain.com/GetDynamicJS?domagic=1>
</script>

Now user is embedding more than of the above and when user mouse over's
the image output of first1 than function getting called is script
loaded in last ... thus error, as that script don't have the relevant
data for it ...
A second FunctionDeclaration for the same identifier creates a new Function
object and replaces the former reference with a reference to the new
object. Are you having that problem?
Any solution for ?
It is not clear why the user would include the same code twice, particularly
because you have showed none of it (not even a URL). The only reason I can
think of is that what is generated here does not contain only "static"
FunctionDeclarations. So the most reasonable approach would be to have one
resource serving the "static" declarations, and another one serving
the "dynamic" code.
Following possible solutions look feasible to me?
1) Somehow I get a static variable and all the JS loaded from my domain
will keep data in that static variable, how to implement it, im not
sure :)
There is no such thing as a static variable, ECMAScript implementations in
HTML UAs do not provide such an attribute for its identifiers. However, if
the "static" part of the code defined an common object, and the "dynamic"
part would add properties to that object, overwriting one property value
with another could be avoided. An Object object or an Array object could
serve that purpose.
2) This is crude, but how about I dynamically give method names of
events in script such that there are no duplicate function names, but
this will again bring lot of other complexity and might need usuage of
eval which is evil and I'll look some option for not using it rather


Probably not. However, it is difficult to come up with helpful suggestions
without knowing what exactly is going on.

Have a look at <URL:http://pointedears.de/hoverMe> (Read the Source, Luke).
PointedEars
Apr 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
15
by: Hemant Shah | last post by:
Folks, We have an SQL statement that was coded in an application many years ago (starting with DB V2 I think). When I upgraded to UDB 8.2, the optimizer does not use optimal path to access the...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
19
by: Larry Smith | last post by:
Hi there, When I run the following on my app's primary thread: System.Type.GetType("System.Windows.Forms.Form") It works as expected. If I then launch a thread via the "BackgroundWorker"...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
1
by: wenijah | last post by:
Hi everyone! First thank you for reading this post and yes, you probably already see that kind of topic title somewhere but the problem I've got today might be different than the 100 topics I've...
11
by: =?ISO-8859-1?Q?Jean=2DFran=E7ois_Michaud?= | last post by:
Context: I'm trying to compare XML tree fragments and I'm doing so by outputting the attributes of each element in the tree and outputting it to a string then normalizing the strings. Then I'm...
10
by: DavidPr | last post by:
I'm having a problem putting entries into a table. I have a job board and I want to prevent certain companies from being able to register - again. I don't allow certain type ads, so when they...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.