Hi,
Thanks alot in advance. I got the following two functions in my
javascript which work fine in Firefox 1.5 but not in IE6. Can someone
please help? Thank you again.
--------------------snip---------------------
function myClass(){
var self = this;
}
function defaultAction() {
myClass.prototy pe.callOut = eval("function (){ " +
"alert('tes ting myClass'); " +
"}");
myObject = new myClass();
if( typeof(myObject ) == 'undefined' ){
alert("myObject is not defined");
}
else if( typeof(myObject ) == 'function' ){
alert("myObject is a function");
}
else{
alert("myObject is " + typeof(myObject ));
}
for (property in myObject) {
alert("myObject has property - " + property);
}
myObject.callOu t(); // Problem appear here. IE complains Object
Expected
} 4 3436
DamonChong wrote: Hi,
Thanks alot in advance. I got the following two functions in my javascript which work fine in Firefox 1.5 but not in IE6. Can someone please help? Thank you again.
A couple of tips when posting code: do not use tabs, use 2 or 4 spaces
for indentation and manually wrap code at about 70 characters to
prevent auto-wrapping. Also, reduce your test case to the minimum
required (though here that isn't much of an issue).
--------------------snip--------------------- function myClass(){ var self = this; }
function defaultAction() { myClass.prototy pe.callOut = eval("function (){ " + "alert('tes ting myClass'); " +
Eval is almost never required:
myClass.prototy pe.callOut = function (){
alert('testing myClass');
}
"}"); myObject = new myClass(); if( typeof(myObject ) == 'undefined' ){ alert("myObject is not defined"); } else if( typeof(myObject ) == 'function' ){ alert("myObject is a function"); } else{ alert("myObject is " + typeof(myObject )); } for (property in myObject) { alert("myObject has property - " + property); } myObject.callOu t(); // Problem appear here. IE complains Object Expected }
The following works fine in Firefox and IE 5.2:
function myClass(){
var self = this;
}
function defaultAction() {
myClass.prototy pe.callOut = function (){
alert('testing myClass');
}
myObject = new myClass();
alert("myObject is " + (typeof myObject) );
for (property in myObject) {
alert("myObject has property - " + property);
}
myObject.callOu t();
}
defaultAction() ;
--
Rob
Thanks alot Rob. The problem is I need the eval() method as I don't
know what is the functions that might be created dynamically during
runtime. In this case, I simply coded the eval("function( ).....") but
in future it could be like below,
myClass.prototy pe.callOut = eval(strval); // where strval is a String
variable
I guess it is abit convulated but surprising it works fine in Firefox.
Is this way of dynamically creating a function supported in IE 5 and
above?
Thank you again.
Damon Chong wrote: Thanks alot Rob. The problem is I need the eval() method as I don't know what is the functions that might be created dynamically during runtime. In this case, I simply coded the eval("function( ).....") but in future it could be like below,
myClass.prototy pe.callOut = eval(strval); // where strval is a String variable
I guess it is abit convulated but surprising it works fine in Firefox. Is this way of dynamically creating a function supported in IE 5 and above?
I can't comment on that in general, I'm testing on Mac OS at the
moment so IE 5.2 is all I can do.
What you are trying to do does not appear to be much different from
using JSON, here is another alternative (tested in Safari, Firefox &
IE 5.2):
<script type="text/javascript">
var myObject;
var funcBody = "alert('tes ting myClass')"
function myClass(){
var self = this;
}
function defaultAction()
{
myClass.prototy pe.callOut = new Function(funcBo dy);
myObject = new myClass();
for (property in myObject) {
alert("myObject has property - " + property);
}
myObject.callOu t();
}
defaultAction() ;
</script>
There is a (rather long) discussion on eval and JSON here, but Jim
Ley's resonponse seems pretty good:
<URL: http://groups.google.com/group/comp....70fb75d49557a7
--
Rob
Thanks alot Rob, I tried it out on IE6 and it is working now. Your tips
were very helpful in solving my problem. Thanks again! =D This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fabri |
last post by:
I would like to ask you the following:
I use Macromedia Dreamweaver as an editor for HTML and Js.
It also writes some js functions to simply validate forms.
I always used it with no bugs.
Till now. This is the problem (and the page):
|
by: goga |
last post by:
Hi there,
The following simple validation code works in internet explorer but
doesn't in firefox.
Specifically, in firefox shows the alert message and then loads the
action page anyway.
Any help appreciated!!
<head>
|
by: dasayu |
last post by:
Hi,
I have a custom object called gridWidget.
I am consistantly getting an error in FireFox when I click on an href,
which calls a function defined on the object. The generated link looks
similar to:
javascript:gridWidget.editColumn(3, 3,
'PDDSectionForm', 'pdd_link', ..)
The above works fine in IE.
|
by: ranger7419 |
last post by:
I'm trying to figure out why this script will work in IE 6 but not
Firefox, and so I need someone here with a far better grasp on
javascript to explain this. Basically, I have a page with several
thumbnails. Above these thumbnails I placed a large picture with text
next to it to describe what the picture is about. So, when you click a
thumb, the large pic AND text change dynamically to reflect the
thumbnail -- see...
|
by: Dave |
last post by:
Hi,
I've been trawling the web for answer to my problem with no luck
although I'm hardly alone it seems!
Below is the generated source for an ASP page that posts a value called
'album' to another ASP page. The other page retrieves the value with
Request.Form('album'); On Firefox this works fine every time. On IE6, I
always get nothing. I'm pretty sure it's the posting side that is at
fault, so that's what I've shown here. Oh, I tried...
| |
by: DavidJColbran |
last post by:
Hello - new to the board and wondering if anyone can help with this. I have a site developed with the CMS ModX.
It has a CSS UL list menu on the left hand side that needs to have roll-overs and a way to show location.
The solid background colour, is to indicate which page the visitor is on, works fine with Firefox - but doesn't work with IE 6 and for the life of me I can't figure out where in the CSS I've gone wrong.
At the moment I'm...
|
by: hardcorey |
last post by:
i basically have a couple songs that ive made on my site, and im using an onClick event to play each song. basically the onClick event calls the javascript function.
heres my javascript:
function playMusic(thisSong)
{
if(thisSong == 1)
{
|
by: dmk |
last post by:
Hi All,
function getWindowSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
|
by: mike57 |
last post by:
The minimal AJAX script below works in Firefox, but not in IE, Opera, or Chrome. I could use some suggestions or referrals to resources that will help me get the script working in other browsers.
Before there are six characters entered in the CAPTCHA code field, the 'Send' button is supposed to be disabled. When there are at least six characters in the CAPTCHA code field, the script attempts to verify the CAPTCHA w/AJAX. If it verifies, it...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |