/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Need help with javascript.

Hey all

I need help from javascript expert to see where did i go wrong in my codes. Reason being when i open it now it not working compare to when i open it last time. So i need help in debugging my codes. As for the external javascript i believe it is working cause i tested it in a blank html file. But when i integrate into this webpage which i building for educational purpose it like not responding to the event. So if any expert is around tonight please reply soon. Needed to submit by tomorrow.

======

codes in html files
======

<script type=”text/javascript” src=”wz_tooltip.js”>
<!–
function popup(url)
{
var width=500;
var height=350;
var left=(screen.width-width)/2;
var top=(screen.width-width)/2;
var params=’width=’+width+’,height=’+height;
params +=’, top=’+top+’, left=’+left;
params +=’, directories=no’;
params +=’, location=no’;
params +=’, meunbar=no’;
params +=’, resizeable=no’;
params +=’, scrollbars=no’;
params +=’, status=no’;
params +=’, toolbar=no’;
newwin=window.open(url,’windownames’, params);
if(window.focus) {newwin.focus()}
return false;
}

//–>
</script>

<!–Begin of table–>
<table border=”0″ align=”center”>
<tr><th align=”center”><h2>History of Singapore</h2></th></tr>
<tr><td align=”center”>Mouse over to see title and click on the dots to learn the history</td></tr>
<tr><td>
<!–Begin of imagemap–>
<img src=”Singapore_map_w.jpg” alt=”” usemap=”singapore” border=”0″ align=”center”>
<map name=”singapore”>
<area name=”1600″ shape=”circle” coords=”269,447,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘Influence of India and Thailand’)”
onmouseout=”UnTip()” >

<area name=”1800″ shape=”circle” coords=”200,401,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘Jostling of power between the Dutch and British’)”
onmouseout=”UnTip()” onclick=”popup(‘popup/1800.html’)”>

<area name=”1819″ shape=”circle” coords=”56,404,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘Modern Singapore and Sir Stamford Raffles claimed’)”
onmouseout=”Untip()” onclick=”popup(‘popup/1819.html’)”>

<area name=”1875″ shape=”circle” coords=”86,316,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘Singapore population grew in number’)”
onmouseout=”Untip()” onclick=”popup(‘popup/1875.html’)”>

<area name=”1900″ shape=”circle” coords=”150,263,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘Singapore the Straits Settlement’)”
onmouseout=”Untip()” onclick=”popup(‘popup/1900.html’)”>

<area name=”1910″ shape=”circle” coords=”163,333,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘Three Major Ethnicities vs British’)”
onmouseout=”Untip()” onclick=”popup(‘popup/1910.html’)”>

<area name=”1920″ shape=”circle” coords=”276,254,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘Origins of Singlish’)”
onmouseout=”Untip()” onclick=”popup(‘popup/1920.html’)”>

<area name=”1950″ shape=”circle” coords=”478,361,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘Popularity of English on the rise’)”
onmouseout=”Untip()” onclick=”popup(‘popup/1950.html’)”>

<area name=”1960″ shape=”circle” coords=”385,431,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘Studies of Singlish’)”
onmouseout=”Untip()” onclick=”popup(‘popup/1960.html’)”>

<area name=”1965″ shape=”circle” coords=”360,360,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘Popularity of English on the rise – part 2’)”
onmouseout=”Untip()” onclick=”popup(‘popup/1965.html’)”>

<area name=”1975″ shape=”circle” coords=”274,378,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘The main language in Singapore’)”
onmouseout=”Untip()” onclick=”popup(‘popup/1965.html’)”>

<area name=”1980″ shape=”circle” coords=”270,328,6″ href=”javascript:void(0)”
onmouseover=”Tip(‘The badge for most Singaporean’)”
onmouseout=”Untip()” onclick=”popup(‘popup/1980.html’)”>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Kostas_ZotosJul 31.2008 — Hi,

The embeded code (the "popup" function) will be executed only when the external JS file failed to load.. Since the "wz_tooltip.js" loaded normally the embeded script just ignored..

(You have set the "popup" function as the alternative script inside your external script declaration, which means that embeded scipt "popup" function will be used only in case the external source AS failed to load)

Try this (note in red color the addition):

[CODE]<script type="text/javascript" src="wz_tooltip.js">[COLOR="Red"]</script>[/COLOR]

[COLOR="Red"]<script language="javascript">[/COLOR]
<!--
function popup(url)
{
var width=500;
var height=350;
var left=(screen.width-width)/2;
var top=(screen.width-width)/2;
var params='width='+width+',height='+height;
params +=', top='+top+', left='+left;
params +=', directories=no';
params +=', location=no';
params +=', meunbar=no';
params +=', resizeable=no';
params +=', scrollbars=no';
params +=', status=no';
params +=', toolbar=no';
newwin=window.open(url,'windownames', params);
if(window.focus) {newwin.focus()}
return false;
}

//-->
</script>[/CODE]


Now the above are two different scripts (independnt of each other)..

Regards!

Kostas
Copy linkTweet thisAlerts:
@Angel_icyauthorAug 01.2008 — Thanks Kostas,

Anyway i manage to find a better javascript and got it running.

-------------------------Tooltips javascript codes-----------------------

if (!document.layers&&!document.all&&!document.getElementById)

event="test"

function showtip(current,e,text){

if (document.all||document.getElementById){

thetitle=text.split('<br>')

if (thetitle.length>1){

thetitles=''

for (i=0;i<thetitle.length;i++)

thetitles+=thetitle[i]

current.title=thetitles

}

else

current.title=text

}



else if (document.layers){

document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+text+'</layer>')

document.tooltip.document.close()

document.tooltip.left=e.pageX+5

document.tooltip.top=e.pageY+5

document.tooltip.visibility="show"

}

}

function hidetip(){

if (document.layers)

document.tooltip.visibility="hidden"

}



</script>

<div id="tooltip" style="position:absolute;visibility:hidden"></div>
---------------------------------------------------------------------





So my image map code is now like this shown below:



----------------------------------------------------------------------

<area name="1600" shape="circle" coords="269,447,6" href="javascript:void(0)"

[COLOR="Red"]onMouseover="showtip(this,event,[/COLOR]'Influence of India and Thailand')"

[COLOR="Red"]onMouseout="hidetip()"[/COLOR] onclick="popup('popup/1600.html')">



-----------------------------------------------------------------------

Updated code are in red. Btw, it's a tooltips for image map.



The main source is from here :http://www.dynamicdrive.com/dynamicindex5/texttool.htm
×

Success!

Help @Angel_icy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...