473,386 Members | 1,804 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,386 software developers and data experts.

Need help converting 'onclick' script to 'href' script...

I've searched the web as well as I can for a solution to this problem
but have found nothing and just don't know enough about JavaScript to
figure out what's going. What I'm trying to do is convert this script:

<a href="#"
onclick="MM_goToURL('parent.frames[\'movieA\']','color2.html');return
document.MM_returnValue">TEST</a>

....to something that I can use within a Flash movie, which as far as I
can tell means that it needs to reside in the 'href' (GetURL) attribute
instead of a separate 'onclick' event. I've tried to do this with this
test version:

<a
href="javascript:MM_goToURL('parent.frames[\'movieA\']','color2.html');return
document.MM_returnValue">TEST2</a>

....which seems to be working in Firefox/Mac, but nowhere else (IE and
Safari are the only other browsers I really care about). I'm hoping
that you JS pros will know immediately what the problem is here (other
than the author not knowing what he's doing). Thanks in advance to
anyone who can help.

In case anyone is interested, I'm attempting to setup a Flash-based
portfolio site that displays loaded-on-the-fly content in pop-up
iFrames above the movie (*that* much I've figured out). The script
above references this Macromedia script:

<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>

The only technical hitch I have now is getting this script to do the
popping.

Thanks!
- whit

Dec 26 '06 #1
9 8531
I know that in IE you can do this but its very picky and if you do it
the wrong way it either gives you a blank page or an error. I know for
a fact that I have something like the following code working in IE 5
and above:

<a href="javascript:parent.doSomething('5273')";>

The only real difference between mine and yours is that you have more
than one statement inside the javascript: part. I would recommend
trying to do the same thing except put the return statement inside your
function instead of inline in the javascript: command.

ie try it without the "return
document.MM_returnValue" inside your <a tag.
Oh and looking at it again I know that having " " and ' ' begins to
cause problems in this particular href=javascript notation. I have had
many problems with it in the past. If the above doesnt work I would
recommend remove the escape characters \' as these may be confusing
it. If you can , handle the escape character inside the actual
function.

the simpler that href=javascript command is , the easier it will be
for you to debug, of this im sure. Try to do as much as you can inside
the function.
wh********@gmail.com wrote:
I've searched the web as well as I can for a solution to this problem
but have found nothing and just don't know enough about JavaScript to
figure out what's going. What I'm trying to do is convert this script:

<a href="#"
onclick="MM_goToURL('parent.frames[\'movieA\']','color2.html');return
document.MM_returnValue">TEST</a>

...to something that I can use within a Flash movie, which as far as I
can tell means that it needs to reside in the 'href' (GetURL) attribute
instead of a separate 'onclick' event. I've tried to do this with this
test version:

<a
href="javascript:MM_goToURL('parent.frames[\'movieA\']','color2.html');return
document.MM_returnValue">TEST2</a>

...which seems to be working in Firefox/Mac, but nowhere else (IE and
Safari are the only other browsers I really care about). I'm hoping
that you JS pros will know immediately what the problem is here (other
than the author not knowing what he's doing). Thanks in advance to
anyone who can help.

In case anyone is interested, I'm attempting to setup a Flash-based
portfolio site that displays loaded-on-the-fly content in pop-up
iFrames above the movie (*that* much I've figured out). The script
above references this Macromedia script:

<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>

The only technical hitch I have now is getting this script to do the
popping.

Thanks!
- whit
Dec 26 '06 #2
Thanks a lot for the reply, dalouis. I've done a little tinkering and
am still not have having any real luck. My revised setup is this:

<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+args[i+1]+"'");
return true
}
//-->
</script>

<a
href="javascript:MM_goToURL('parent.frames[\'movieA\']','color2.html')">TEST2</a>

This setup is still working fine in Safari (I had my browser details
wrong in the original message), but in Firefox it's causing the link to
bounce me to a page that just says "false" (you probably could have
told me that by looking at the function). I tried removing the escapes
outright, which broke the setup completely, but I re-read the reply and
realized you meant for me to move them up to the function. Problem is,
I don't have any idea where or how to do that. Any more tips?
dalouis wrote:
I know that in IE you can do this but its very picky and if you do it
the wrong way it either gives you a blank page or an error. I know for
a fact that I have something like the following code working in IE 5
and above:

<a href="javascript:parent.doSomething('5273')";>

The only real difference between mine and yours is that you have more
than one statement inside the javascript: part. I would recommend
trying to do the same thing except put the return statement inside your
function instead of inline in the javascript: command.

ie try it without the "return
document.MM_returnValue" inside your <a tag.

Oh and looking at it again I know that having " " and ' ' begins to
cause problems in this particular href=javascript notation. I have had
many problems with it in the past. If the above doesnt work I would
recommend remove the escape characters \' as these may be confusing
it. If you can , handle the escape character inside the actual
function.

the simpler that href=javascript command is , the easier it will be
for you to debug, of this im sure. Try to do as much as you can inside
the function.
wh********@gmail.com wrote:
I've searched the web as well as I can for a solution to this problem
but have found nothing and just don't know enough about JavaScript to
figure out what's going. What I'm trying to do is convert this script:

<a href="#"
onclick="MM_goToURL('parent.frames[\'movieA\']','color2.html');return
document.MM_returnValue">TEST</a>

...to something that I can use within a Flash movie, which as far as I
can tell means that it needs to reside in the 'href' (GetURL) attribute
instead of a separate 'onclick' event. I've tried to do this with this
test version:

<a
href="javascript:MM_goToURL('parent.frames[\'movieA\']','color2.html');return
document.MM_returnValue">TEST2</a>

...which seems to be working in Firefox/Mac, but nowhere else (IE and
Safari are the only other browsers I really care about). I'm hoping
that you JS pros will know immediately what the problem is here (other
than the author not knowing what he's doing). Thanks in advance to
anyone who can help.

In case anyone is interested, I'm attempting to setup a Flash-based
portfolio site that displays loaded-on-the-fly content in pop-up
iFrames above the movie (*that* much I've figured out). The script
above references this Macromedia script:

<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>

The only technical hitch I have now is getting this script to do the
popping.

Thanks!
- whit
Dec 27 '06 #3
Doesn't look like "bumping" works in newsgroups like this, but I'll try
it anyway. Anybody out there who can shed some light on this issue?

Dec 30 '06 #4
VK
wh********@gmail.com wrote:
Doesn't look like "bumping" works in newsgroups like this, but I'll try
it anyway. Anybody out there who can shed some light on this issue?
You cannot do it on modern browsers with the default Flash player
installation.
javascript:void(codeToExecute) pseudo-protocol trick was good for a
long time but now it's blocked as well.

On IE 6,7 it's simply ignored, on Firefox you'll see a security warning
dialog. It is because the modern Flash player is a sophisticated
programming environment by its own with security policies differing
sometimes from the policies of the browser it is run on (XMLHttpRequest
cross-domain communication is the first comming into my mind).
Respectively it may have his very own security exploits which browser
producers do not want to be held responsible for.

This way either abandon Flash whatsoever or make the entire interface
as one big Flash movie.

Dec 30 '06 #5
Crap. That screws up my plan. I really don't want to enclose the entire
thing in a Flash movie. No wonder the existing setup wasn't working in
any browser that I was testing it in. Still, how is that different from
issuing JS pop-up window commands? The pop-up contact form at this site
still works:
http://www.morris-day.com/home.html (click "Contact Us" then the
"Contact Form" link)

I can make my plan work with actual pop-up windows, I'd just prefer to
use DIVs. At any rate, thanks for the reply, VK.
VK wrote:
You cannot do it on modern browsers with the default Flash player
installation.
javascript:void(codeToExecute) pseudo-protocol trick was good for a
long time but now it's blocked as well.

On IE 6,7 it's simply ignored, on Firefox you'll see a security warning
dialog. It is because the modern Flash player is a sophisticated
programming environment by its own with security policies differing
sometimes from the policies of the browser it is run on (XMLHttpRequest
cross-domain communication is the first comming into my mind).
Respectively it may have his very own security exploits which browser
producers do not want to be held responsible for.

This way either abandon Flash whatsoever or make the entire interface
as one big Flash movie.
Dec 30 '06 #6
VK

wh********@gmail.com wrote:
>. Still, how is that different from
issuing JS pop-up window commands? The pop-up contact form at this site
still works:
http://www.morris-day.com/home.html (click "Contact Us" then the
"Contact Form" link)
Difficult to say - as I said Flash ActionScript may have its own
vulnerabilities and respectively its own bug exploits. From the other
side I see address bar flashing for a sec in the new window but
disappearing after. So maybe they simply do getURL(formPage) with
_target blank - so no javascript usage from movie, pure HTML mechanics,
and the script on formPage does the rest.

I don't want to decompile someone's movie without permission, so I
cannot tell for sure.

See also
<http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager.html#117164>

Dec 30 '06 #7
I should have specified that I created it - years ago, so I didn't
remember what the setup was - and also didn't realize I had the source
file handy. It looks like you're half right:
on (release) {
getURL("javascript:openNewWindow('contact.html','c ontact','height=700,width=800,toolbar,scrollbars,r esizable,left=20,top=20')");
}

All the parameters seem to be contained in the one "URL," so I guess
this is allowed because it's not calling a function elsewhere on the
page?
VK wrote:
Difficult to say - as I said Flash ActionScript may have its own
vulnerabilities and respectively its own bug exploits. From the other
side I see address bar flashing for a sec in the new window but
disappearing after. So maybe they simply do getURL(formPage) with
_target blank - so no javascript usage from movie, pure HTML mechanics,
and the script on formPage does the rest.

I don't want to decompile someone's movie without permission, so I
cannot tell for sure.

See also
<http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager.html#117164>
Dec 30 '06 #8
VK
wh********@gmail.com wrote:
I should have specified that I created it - years ago, so I didn't
remember what the setup was - and also didn't realize I had the source
file handy. It looks like you're half right:
on (release) {
getURL("javascript:openNewWindow('contact.html','c ontact','height=700,width=800,toolbar,scrollbars,r esizable,left=20,top=20')");
}

All the parameters seem to be contained in the one "URL," so I guess
this is allowed because it's not calling a function elsewhere on the
page?
That is a fancy matter. On my Firefox 1.5 / Flash 9.0 plugin for your
side I'm indeed getting popup window. At the same time even for a
_local_ page having openNewWindow function called from flash by
getURL("javascript:openNewWindow()") I'm getting security alert.

I'm admittedly not a profound specialist of Flash <JavaScript
bridging, maybe it's time for a more specific group like
<macromedia.flash.actionscript>. Some answer can be also hidden at
<http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html#119065>

If you come up with an explanation, it would be hice to have it posted
here.

Dec 30 '06 #9
I'll open up a conversation on that group and let you know if the
question gets answered. Thanks for your feedback, VK.
VK wrote:
wh********@gmail.com wrote:
I should have specified that I created it - years ago, so I didn't
remember what the setup was - and also didn't realize I had the source
file handy. It looks like you're half right:
on (release) {
getURL("javascript:openNewWindow('contact.html','c ontact','height=700,width=800,toolbar,scrollbars,r esizable,left=20,top=20')");
}

All the parameters seem to be contained in the one "URL," so I guess
this is allowed because it's not calling a function elsewhere on the
page?
Dec 30 '06 #10

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

Similar topics

3
by: Steve | last post by:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same...
5
by: Mike | last post by:
In my previous post, I wrote: > ... > GOAL: (very simple) Provide a hyperlink which, when clicked, > calls a javascript function which opens a new URL. > ... > PROBLEM: The following code...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
28
by: Randy Starkey | last post by:
Hi, Does anyone know where I can get a script that show a little plus sign after a line of text, that when you click the plus sign, more text is revealed on that same page, like a continuing...
7
by: fox | last post by:
Hi, Lacking javascript knowledge, I just realized why my project has a bug. I am using ASP to loop through a set of records while it creates URLs with a querystring that has a single value pair....
11
by: GaryB | last post by:
Hi Guys, I've been battling with this one for hours - I hope that you can help me! My code modifies the <aon a page, from a standard document link into a link with a tailored onclick event. ...
1
by: bhosalevivek | last post by:
I did this code from Dynamic Drive DHTML. it's working properly, but now I need submenu for "Submenu 1.2", means when I take mouse on "Submenu 1.2" I need to display "Submenu 1.2.1". I try to do...
2
by: registry | last post by:
<%@Language="VBSCRIPT" CODEPAGE="1252"%> <html> <head> <title>Registry Network Hospital Detail</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script...
5
by: dangt85 | last post by:
Hello, I have the following page: ... <style type="text/css"> body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.