Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This script only works in IE, any ideas? 1

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
0
0
US
This script works fine in IE...the page responds as though the button were clicked. But not in Firefox, Opera or Safari.
Code:
<script language="javascript" type="text/javascript"><![CDATA[<!--
/* Service-specific script goes here */
function func1()
{
 document.getElementById('btnSave').click();
}
window.onload=func1; 
//-->      ]]></script>
...and the button looks like this:
Code:
<input type="button" value="" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent(concat('__insert;__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}" style="border-style: none; border-color: #FFFFFF; height: 2px; background-color: #FFFFFF;" />
Any ideas?
 
That's because your using getElementBy[red]Id[/red] but your button doesn't have an ID. IE mistakenly uses the name property as the ID so it works.

Give your button and actual id of btnSave and it will work in the other browsers.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Thanks Vacunita, that was it! Really appreciate it. It's always these little things that seem to get past me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top