By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,442 Members | 1,327 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,442 IT Pros & Developers. It's quick & easy.

REPOST: Macormedia Javascript function in PocketIE

P: n/a
Reposted due to no response.

Hi guys

I am using Dreamweaver to create an intranet site that is to be accessed by
a PDA, but I have hit a problem with JavaScript under Pocket Internet
Explorer. I have added a standard DW behaviour (function to non-DW peeps)
that simply redirects the user to another page and is fired when a user hits
a button, but PocketIE seems to do nothing with it. I don't receive an error
message, line number or anything! Any help on finding / fixing the problem
would be gratefully appreciated - not being a JavaScript(let alone js on a
pda) person, I don't.know where to start.

Here's the code:

<script language="JavaScript" 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>

Regards
James
tgl

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
James Leech wrote:
Reposted due to no response.

Hi guys

I am using Dreamweaver to create an intranet site that is to be accessed by a PDA, but I have hit a problem with JavaScript under Pocket Internet
Explorer. I have added a standard DW behaviour (function to non-DW peeps) that simply redirects the user to another page and is fired when a user hits a button, but PocketIE seems to do nothing with it. I don't receive an error message, line number or anything! Any help on finding / fixing the problem would be gratefully appreciated - not being a JavaScript(let alone js on a pda) person, I don't.know where to start.

Here's the code:

<script language="JavaScript" 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]+"'");

Does this code work in *any* browser? It appears to be something of
an
abomination! Maybe it makes more sense if you'd posted whatever the
arguments are.

If all you want to do is click on a button and go somewhere, and you
apparently don't want to use a normal <a href="">, why not:

<form action="">
<button onclick="
document.location='http://www.news.com'
">Go to news.com</button>
</form>

Or is simplicity dead?

--
Rob

Jul 23 '05 #2

P: n/a
On Wed, 22 Dec 2004 11:59:06 -0000, James Leech
<ja***@graphics-line.co.uk> wrote:

[snip]
I have added a standard DW behaviour (function to non-DW peeps)
All the code I've seen generated by DW is, quite frankly, crap. The code
you've posted is no exception.
that simply redirects the user to another page
Javascript should never be used for navigation, but as you're authoring
for an intranet, you can probably get away with it.
and is fired when a user hits a button,
Any reason why you can't just use a link? You're obviously going to have
much better luck using standard functionality.

[snip]
<script language="JavaScript" type="text/JavaScript">
[Unrelated] The language attribute is deprecated (has been for over six
years) and redundant when the (required) type attribute is present.
<!--
[Unrelated] Hiding scripts is also an out-dated practice.
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]+"'");


It's possible that the eval function is unimplemented. ECMA-327, which
defines a subset of ECMAScript, allows implementations to omit a few
features to reduce load on the environment. However, as I don't have
access to PocketIE I couldn't say for certain.

If you're just altering the URL for the current document, you could
simplify the function to

function goToURL(url) {location.href = url;}

If you're using frames (and you generally shouldn't):

function goToURL(url, frame) {
(frame || window).location.href = url;
}

If the frame argument is omitted, the current document will be altered.

If you really need the functionality provided by DW's original function:

function goToURL() {
for(var i = 0, n = arguments.length; i < n; i += 2) {
arguments[i].location.href = arguments[i + 1];
}
}

As you can see, eval is entirely unnecessary. The author's just clueless.

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.