pop up URL based on image map ... return false for the main window

A

ameyas

hi all,

i am using an image which has image map and i provide the href action
url. i have provided the url to open a pop up window like
"javascript:window.open('www.google.com');" but on clicking the image,
the page (main window) gets refreshed in the background the pop up
opens as desired.

is there a way to cancel the refreshing of page ? i tried

"javascript:window.open(www.google.com); return false;" gives error
so itried
"javascript:new function() { window.open(www.google.com); return
false; }"
but that didn stop refreshing the page either.

i also tried adding onclick function and then return false from there
but in that case the map does not work (no pop up) and i dont get the
required details from the image area.

how do i achieve this ?

thanks & regards
amey
 
E

Evertjan.

ameyas wrote on 01 mrt 2007 in comp.lang.javascript:
"javascript:window.open(www.google.com); return false;" gives error

window.open expects a string for an url,
litteral strings need to be deliminated by quotes in javascript,
and needs http://:

<a
href="javascript:window.open('http://www.google.com'); return false;"

Better, because not everyone has javascript active, is:

<a
href='http://www.google.com/' target='_blank'
onclick="window.open(this.href); return false;"

and in this sparse case, you would not need any javascript anyway:

<a
href='http://www.google.com/' target='_blank'
 
A

ameyas

thanks evertjan

it ain that straightforward. i am acutally using jfreechart (java
library) to generate chart images. i need to pass string as argument
which is used as prefix in generating maps for that chart.
so i wanted to know if is there any way where by i can cancel the
refreshing.

i do not have a href anywhere.
its all handled internally by jfreechart to generate map. all i can do
is pass some javascript statement within the string.

so target _blank should not work in my case.
all i have is access to img tag which uses auto-generated map. and
string URL which can contain javascript statements like
javascript:window.open(); ..... return false etc.
this string i pass as parameter to jfreechart APIs to generate image
map.

hope i made myself clear :)

thanks & regards
amey
 
A

ASM

ameyas a écrit :
thanks evertjan

it ain that straightforward. i am acutally using jfreechart (java
library)

where can we see this curiosity (in action) ?
to generate chart images. i need to pass string as argument
which is used as prefix in generating maps for that chart.
so i wanted to know if is there any way where by i can cancel the
refreshing.

i do not have a href anywhere.

you have certainly one href (and more) !
if not, why to create a map ?
its all handled internally by jfreechart to generate map. all i can do
is pass some javascript statement within the string.

What is this tool that can do almost nothing ?
Of course you have no NotePad or similar ?
hope i made myself clear :)

Hope you can code at home with your NotePad to correct what your java
tool can't make.

Any way Evertjan has given you what to type :

with your java tool when it asks url :

javascript:window.open('http://www.google.com');return false;

the real url is between '
 
A

ameyas

Hi ASM,

jfreechart (http://www.jfree.org/jfreechart) is not a tool, its an
opensource java library (not an editor) to generate chart images
dynamically based on some data. it supports drill down of charts using
image maps so based on where you clicked on the chart, you can further
drill down the chart with selected info.

now it takes URL as the parameter and it automatically appends the
parameters based on the image map.
for ex if you have a yearly bar chart to show sales in 12 months, and
when the user clicks on one particular month, the selected month will
be appended to the URL prefix (which i provide).

now here i can only pass string URL prefix. but i can pass URL
something like
"javascript:window.open('http://localhost:8080/myServlet');"
this will hit the given URL and append the selected month as parameter

now i wanted to know if is there any statement (return false din work)
which can stop refreshing the background page?
event.cancelBubble = true din work as well.


thanks & regards
amey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top