473,785 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IE: "Expected Identifier" error :(

5 New Member
Hi Everyone,
Here is a part of javascript code that works well in FF2 but shows above error in IE6 and error "missing name after . operator" .
Expand|Select|Wrap|Line Numbers
  1.  
  2.   function PopUp(idf,stepX,stepY,speed){
  3.  
  4.     this.idf=idf;
  5.     this.popXStep=stepX;
  6.     this.popYStep=stepY;
  7.     this.popSpeed=speed;
  8.     this.popLeft=0;
  9.     this.popTop=0;
  10. };
  11.  
  12.     PopUp.prototype.relocX=function() {
  13.      if(xon==0){this.popLeft=this.popLeft-this.popXStep;}
  14.     else{this.popLeft=this.popLeft+this.popXStep;}
  15.  
  16.     if(this.popLeft<0){xon=1;this.popLeft=0;}
  17.     if(this.popLeft>=(chX-ohX)){xon=0;this.popLeft=(chX-ohX);}
  18.     if(ie){
  19. window.alert("here!");
  20.         this.idf.style.left=this.popLeft+document.body.scrollLeft;
  21.         this.idf.style.top=this.popTop;
  22.     }
  23.     else if (ns4){
  24.         document.(this.idf).pageX=this.popLeft+window.pageXOffset;
  25.         document.(this.idf).pageY=this.popTop;
  26.     }
  27.     else if (ns6){
  28.         document.getElementById(this.idf).style.left=this.popLeft+window.pageXOffset
  29.         document.getElementById(this.idf).style.top=this.popTop
  30.     }
  31.  
  32. };

Here is the error copied from NS JS Console:
Error: missing name after . operator
Source File: file:///C:/templates/test.html
Line: 105, Column: 17
Source Code:
document.(this. idf).pageX=this .popLeft+window .pageXOffset;


Well it's not because of a reserved word use. Its an addition in my project,
I am generating a no. of pop ups on one page. Deadline is in 10 hrs! Can someone please help?
May 29 '07 #1
8 2737
mrhoo
428 Contributor
IE does not understand the pageX or pageX offset property
May 29 '07 #2
trappedIntoCode
5 New Member
IE does not understand the pageX or pageX offset property
Yeah, well but the pageX and pageY are used for NS4, not IE, please notice the If--else blocks. I forgot to mention that I have already detected the browser versions. :)
May 29 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
See the compatibility tables for different browsers for the mouse position.

It might also help to read the Find Position page.

As far as browser sniffing is concerned, that's bad practice. Use object detection instead - see link
May 29 '07 #4
trappedIntoCode
5 New Member
Thanks links acoder. I did try following:

Expand|Select|Wrap|Line Numbers
  1. if(ie){
  2.  
  3.         document.this.idf["style.left"] = this.popLeft + document.body.scrollLeft;
  4.         document.this.idf["style.top"]=this.popTop;
  5.     }
and also

Expand|Select|Wrap|Line Numbers
  1. if(ie){
  2.  
  3.        document["this.idf"].style.left = this.popLeft + document.body.scrollLeft;
  4.        document["this.idf"].style.top = this.popTop;
  5.     }
This time, IE showed no error, but did not behave as intended also.
THe two pop ups move n FF and NS8, but not in IE6. When I debugged with
.NET, I found out that "style" was undefined!
Then finally, I went back to basics:

Expand|Select|Wrap|Line Numbers
  1. if(ie){
  2.         document.getElementById(this.idf).style.left=this.popLeft+document.body.scrollLeft;
  3.         document.getElementById(this.idf).style.top=this.popTop+document.body.scrollTop;
  4.     }
  5.     else if (ns6){
  6.         document.getElementById(this.idf).style.left=this.popLeft+window.pageXOffset
  7.         document.getElementById(this.idf).style.top=this.popTop+window.pageYOffset
  8.     }

Now it works fine in NS8,IE6 and FF2!! and so I was able to sleep like a innocent kid who has just finished his exams.........: )
But I still dont know why
document["this.idf"].style.left
did not work. Why there are so many compatibility problems? I am new to javascrip, I had been programming all my days with Java and VB/VC.
I have already used Prototype for one of my projects but because, its JS file was 57KB and I could use additional 30Kb of prototype. Hushshsh....... .
anyways, problem is solved. :)
May 29 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
Unfortunately, we have to live with that when programming in Javascript.

Browser vendors sometimes add their own proprietary properties or just plainly do not follow the standards. Sometimes they make an attempt but fail. To top it all, Microsoft is the worst culprit and their browsers also happen to be the most popular.

Anyway, glad you got your problem solved even though I may not entirely agree with the coding.
May 29 '07 #6
trappedIntoCode
5 New Member
Yip, Microsoft seems to be the biggest culprit, their Corporate strategies have always overshadowed their Softwares (non-standard implementations , borrowing syntaxes (c# vs Java) etc.). Anyways.
I may not entirely agree with the coding.
???
Can you suggest a better way? eg. using Object Detection?
May 29 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Can you suggest a better way? eg. using Object Detection?
It's not that difficult. Read the article on Object Detection which I linked to earlier.

Basically, replace if(ie), if(ns), etc. with detection of objects. So your code will be very similar - just that it will detect objects rather than browsers. This will make it future-proof. Many browser-sniffing programs/code fell apart with the introduction of IE7, because the code was checking for IE6, IE5, etc.

So, in your code, for example, you check for pageXOffset. IE doesn't support it, so it executes the second code block instead. If future versions of IE do support it (I'm not sure about IE7), your code doesn't break.
May 30 '07 #8
trappedIntoCode
5 New Member
It's not that difficult. Read the article on Object Detection which I linked to earlier.

Basically, replace if(ie), if(ns), etc. with detection of objects. So your code will be very similar - just that it will detect objects rather than browsers. This will make it future-proof. Many browser-sniffing programs/code fell apart with the introduction of IE7, because the code was checking for IE6, IE5, etc.

So, in your code, for example, you check for pageXOffset. IE doesn't support it, so it executes the second code block instead. If future versions of IE do support it (I'm not sure about IE7), your code doesn't break.

Thanks acoder. I will try that. It sounds much better than browser detection.
May 30 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2724
by: Rick | last post by:
I wrote the following code as part of a page where users can reorder a list of items by highlighting an item in a list box and clicking an "up" or "down" button to move the items around. The code below is for the up and down buttons along with a reset button (which reloads the list as it was originally) and a change button which applies the changes. In Explorer and Safari for Mac, this code works flawlessly. When I tested on Explorer in...
2
9801
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton in a link. that function can have parameters for URL and window name passed to it. This works peachy in Firefox (1.0). With IE 6 (6.0.29) on two separate computers, I get an "onject expected" error. Going to the MS-based debugger just tells me...
6
6639
by: craigbeanhead | last post by:
Hi, I'm teaching myself C from K&R2. I've come across something that I really don't understand. When I try to compile the following code (in VC++7), I get an "undeclared identifier" error. When I move the second integer declaration to the beginning of the function, it compiles and runs correctly. I'm sure I read that you could declare a variable anywhere in a code block, as long as you don't attempt to use it *before* the declaration....
3
2270
by: rdi | last post by:
The import statements weren't copy/pasted, but everything INSIDE the class WAS copy pasted from the help file. Starting with the myMail.From line and going down to the SmtpMail.Send line, EVERY line results in a "Declaration Expected" error. -- RDI (remove the exclamation from the email address) Imports System.Web Imports System.Web.Mail
3
3194
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something missing from the code? Thanks - Jon Private Sub MakeParentTable() ' Create a new DataTable. Dim myDataTable As Datatable = New Datatable("ParentTable")
1
9319
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "PAR.PAR_Status" could not be bound. The multi-part identifier "Salary.New_Salary" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part...
2
2469
by: jman | last post by:
i'm getting an "object expected" error in ie - not ff. in the BODY onload attribute i call a function that's loaded from an external file. i've narrowed the error down to the fact it cannot find this function. <script src="external.js">
2
5744
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%= ViewData %>" /> -
9
11197
by: Rohit | last post by:
I am trying to initialize an array whose initializers depend on value of Enums. I take enum and then decide the initializer value, so that even if enum value changes because of addition to list even then I should be able to get correct value for the array element. I need value and state to be present in a single byte thats why I use macros. Here is what my code look like: typedef enum
0
9645
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, 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...
0
9481
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,...
0
10336
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, 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...
0
10155
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 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...
1
10095
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,...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
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...
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.