--Joey
Joey...
Showing some relevant code will get you an answer faster.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Joey wrote:
> I'v gotta modal window called using - window.ShowModalDialog("MyPage.aspx")
> Inside this page I'v got an "a href" calling a java script inside the modal
> dialog
> But when click the a href, instead of running the script, the modallic
> window opens a new window looking for my Java script function
Don't use
<a href="javascript: code">
simply use
<a href="#"
onclick="code; return false;">
--
Martin Honnen
http://JavaScript.FAQTs.com/
> simply use
> <a href="#"
> onclick="code; return false;">
Actually, I'd recommend against href="#" too.
If Javascript is not available, the link will be unusable. That is bad
design. You should use some href that makes sense, if nothing else
href="whyThisPageNeedsJS.html" . The "#" link will either do nothing,
jump to the top of the page, or reload the page, depending on the
browser. That is not what you want (except perhaps the "do nothing"
option). (Btw, the shortest legal URL is the empty one, so you could
also write href="", which is, if nothing else, shorter, and has less
chance of reloading the page).
If you can't find any href that makes sense, it is a good sign that you
are using the wrong HTML element. What you have is something that has
an effect when clicked, not something that links to another ressource.
That is the job of a button, not a link, so just use a button and you
won't have to invent a meaningfull URL for a href.
/L
--
Lasse Reichstein Nielsen - l...@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
-- Joey
"Roland Hall" <nobody@nowhere> wrote in message
news:ukBowMj7...@TK2MSFTNGP11.phx.gbl...
Joey...
aonClick() is not a valid command so it would have to be a function.
It is also not relevant code. I wanted you to show the link you're
referring to that you have inside the Modal window.
You're not opening a Modal window, you're inside a Modal window with an
'href' link calling a javascript script.
So, we need to see the link and possibly also the script.
-- Joey
"Roland Hall" <nobody@nowhere> wrote in message
news:#vekCOt7...@TK2MSFTNGP12.phx.gbl...
Lasse Reichstein Nielsen wrote:
> Martin Honnen <Martin...@t-online.de> writes:
>
>
>>simply use
>> <a href="#"
>> onclick="code; return false;">
>
>
> Actually, I'd recommend against href="#" too.
>
> If Javascript is not available, the link will be unusable. That is bad
> design.
Well, the original poster was talking about a modal window and that can
only be open if JavaScript is available.
The syntax, "javascript::alert()" is either a) wrong or b) new to me.
...basically you would only use *one* colon.
To be honest, if it works in a normal window, I dunno why I doesn't in a
modal.
Maybe they're more fussy about syntax.
Try the correct version with a single colon first.
If that doesn't work.....
As a previous poster has said, executing functions isn't really the
proper use for links. Their use in this way, with the "javascript: ..."
protocol is a bit of a hangover from the "old days".
Really, you should write: onclick = "alert( )" .. and that's it.
If the function you are calling is actually declared on the main window,
then you'll need to get the function via that, with a reference to the main
window
(which needs to be passed as an argument when the modal is opened, I
believe)
So
onclick = "[ openerRef ].[ functionName ]( args )"
I can see why you might still want to use a link href though.
It can make rollovers easier with a little canny use of CSS.
Luck to you
Jude
Joey <n_n...@hotmail.com> wrote in message
news:uCOUEjt7...@tk2msftngp13.phx.gbl...
Actually I agree with most Jude wrote here and I must say I missed the
double colon. I'm almost sure it is just a typo here since I doubt Joey
copy/pasted.
However, I am also having the same issue so I'm not sure if it is possible
with Modal/Modeless windows. This may be by design but I've read some
articles that say you need to pass everything to them through the arguments.
As one example of a normal popup window vs a modal/modeless window, the
filename is not required. You can reference it as:
var w = window.open('','windowname','width=200, height=100');
...and then reference that window with the variable w. Modal windows do not
appear to allow this and require you pass through the arguments parameter.
I'm working with showModalDialog and showModelessDialog. If you're working
with something else, then please let me know.
However, you can turn everything off in a normal popup window so does your
window have to be modal for what you want?
You know, you cannot even right-click a Modal window. You can but nothing
returns.
To add, here is an interesting article, although dated, which might explain
some things. There are errors in this document because you can work with
Modals and frames and with Modals -> Modals passing arguments.
http://developer.netscape.com/viewsource/goodman_modal/goodman_modal.html
Notice this code WILL work on a normal window,
BUT, running it on a modallic window will a cause a different window to be
opened!
Thanks again
-- Joey
"Roland Hall" <nobody@nowhere> wrote in message
news:ONd4jf77...@tk2msftngp13.phx.gbl...
Script defined in an href attribute should return a url *or* return false to
cancel the default action of clicking on a link (i.e., navigate the current
window to the url specified in the href attribute).
<a href="javascript:myFunc();>Press Me!</a>
with...
function myFunc()
{
//do something useful...
return false;
}
A better choice is to use the onclick event and an empty href...
<a href="" onclick="javascript::myFunc();>Press Me!</a>
In any case, modal/modeless *dialog* windows will open links in a new window
*by design*.
> Try running this line in a normal window - you'll get an empty alert,
> But if your run the same like of code in a modallic window - it will
> open an empty web page!
--
Michael Harris
Microsoft.MVP.Scripting
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp
TechNet Script Center Sample Scripts
http://www.microsoft.com/technet/scriptcenter/default.asp
Download in HTML Help format (searchable and indexed)
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942
WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en
> Joey wrote:
>> <a href="javascript::alert();>Press Me!</a>
> Script defined in an href attribute should return a url *or* return false to
> cancel the default action of clicking on a link (i.e., navigate the current
> window to the url specified in the href attribute).
I think you are confuzing some things here.
It should not return an URL. Whatever it returs is used as HTML code to
*replace* the current page. Returning an URL would give you a blank page
with the URL as text. Returning false would give you a blank page with
"false" written on it.
Generally, you should not use javascript: hrefs at all, but instead
use the onclick attribute:
<a href="thisPageRequiresJS.html" onclick="myFunc();return false;">
This is the correct place to return false from to cancel the normal
behavior of the link. Remember to have a meaningfull URL for people
with Javascript turned off or otherwise unavailable.
> A better choice is to use the onclick event and an empty href...
Indeed, except I don't recommend the empty href.
> <a href="" onclick="javascript::myFunc();>Press Me!</a>
The "::" is one colon too many, but the entire "javascript:" can
be removed. In other browsers than IE, it is merely read as a
label named "javascript". In IE, it does select the language of
the event handler, but Javascript/JScript is the default.
Well, it appears Michael Harris answered the question of whether or not it
is by design to open a new window. I don't use the <a href> anyway and I
have test it with that and with a <span onclick...> and it's the same
issue.
I believe the Modal and Modeless Windows are designed to be menu holders or
custom information dialogs and not so much a usable window, like a popup.
What's confusing is it's called a Modal Window meaning, at least to me, it
should be just like a popup window but maintain focus. However, I find that
I am wrong in this assumption because I've written many popup window
routines and none of them work correctly with the Modal or Modeless as you
have requested.
-- Joey
"Roland Hall" <nobody@nowhere> wrote in message
news:#By9eMP8...@TK2MSFTNGP11.phx.gbl...
No, it's there deliberately so that a malicious site can't display a page
the mimics a trusted Windows system dialog.