NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Javascript Crash When Checking For Undeclared Objects

 
Post new topic   Reply to topic    NetBeans Forums -> Web Client Users
View previous topic :: View next topic  
Author Message
TTCUSM



Joined: 10 Oct 2015
Posts: 11

PostPosted: Mon Oct 12, 2015 1:24 am    Post subject: Javascript Crash When Checking For Undeclared Objects Reply with quote

Hello,

I am using Google Chrome and Netbeans to develop a web application on Mac OS X Mavericks. I did some Googling, and I found that you can use something like this to check to see if a variable is undeclared:

<html>
<head>
<title>Checking Undeclared Variables</title>
</head>
<body>
<script type="text/javascript">
if (typeof (x) == "undefined")
{
alert ("<h1>x is undeclared</h1>");
}
else
{
alert ("<h1>x is declared</h1>");
}
</script>
</body>
</html>

When I run this code from Netbeans in my environment, I get a Javascript exception. However, when I run the same code using Google Chrome and Netbeans on Windows, it works, and I get an alert window saying "x is undeclared". The only difference is the operating system. Are there any known issues with the way Netbeans interprets Javascript on OS X?

BTW, I am using the Netbeans Chrome plugin to launch Google Chrome from my Netbeans IDE to debug this web application. My Chrome instance also has a Netbeans extension installed.


Last edited by TTCUSM on Mon Oct 12, 2015 1:52 pm; edited 1 time in total
Back to top
vriha



Joined: 07 Feb 2013
Posts: 135

PostPosted: Mon Oct 12, 2015 6:04 am    Post subject: Javascript Crash When Checking For Undeclared Objects Reply with quote

What JS exception are you getting? If you run this code from NetBeans,
it is still being evaluated by the browser, not NetBeans. The only thing
wrong (or at least not the best practice) is using == instead of === .
Editor in NetBeans should show you hint about this.


Lada

On 12/10/15 03:24, TTCUSM wrote:
Quote:
Hello,

I am using Google Chrome and Netbeans to develop a web application on Mac OS X Maverick. I did some Googling, and I found that you can use something like this to check to see if a variable is undeclared:

<html>
<head>
<title>Checking Undeclared Variables</title>
</head>
<body>
<script type="text/javascript">
if (typeof (x) == "undefined")
{
alert ("<h1>x is undeclared</h1>");
}
else
{
alert ("<h1>x is declared</h1>");
}
</script>
</body>
</html>

When I run this code from Netbeans in my environment, I get a Javascript exception. However, when I run the same code using Google Chrome and Netbeans on Windows, it works, and I get an alert window saying "x is undeclared". The only difference is the operating system. Are there any known issues with the way Netbeans interprets Javascript on OS X?

BTW, I am using the Netbeans Chrome plugin to launch Google Chrome from my Netbeans IDE to debug this web application. My Chrome instance also has a Netbeans extension installed.



Back to top
TTCUSM



Joined: 10 Oct 2015
Posts: 11

PostPosted: Mon Oct 12, 2015 2:07 pm    Post subject: Re: Javascript Crash When Checking For Undeclared Objects Reply with quote

vriha wrote:
What JS exception are you getting? If you run this code from NetBeans,
it is still being evaluated by the browser, not NetBeans. The only thing
wrong (or at least not the best practice) is using == instead of === .
Editor in NetBeans should show you hint about this.


I'm getting a ReferenceError. I asked this question on a mailing list that handles Google Chrome issues, and I was told that it works just fine if you run Google Chrome on Mac OS X without Netbeans. Therefore, the problem must be with the way Netbeans handles Javascript code.
Back to top
vriha



Joined: 07 Feb 2013
Posts: 135

PostPosted: Tue Oct 13, 2015 8:11 am    Post subject: Javascript Crash When Checking For Undeclared Objects Reply with quote

Could you then please describe exact (as detailed as possible) step by
step instructions to reproduce it?

Thank you,
Lada

On 12/10/15 16:07, TTCUSM wrote:
Quote:
vriha wrote:
Quote:
What JS exception are you getting? If you run this code from NetBeans,
it is still being evaluated by the browser, not NetBeans. The only thing
wrong (or at least not the best practice) is using == instead of === .
Editor in NetBeans should show you hint about this.

I'm getting a ReferenceError. I asked this question on a mailing list that handles Google Chrome issues, and I was told that it works just fine if you run Google Chrome on Mac OS X without Netbeans. Therefore, the problem must be with the way Netbeans handles Javascript code.



Back to top
TTCUSM



Joined: 10 Oct 2015
Posts: 11

PostPosted: Wed Oct 14, 2015 1:44 am    Post subject: Re: Javascript Crash When Checking For Undeclared Objects Reply with quote

Steps to reproduce:

1) Install Netbeans IDE, with the Google Chrome plugin.
2) Install Google Chrome, with the Netbeans extension.
3) Create a new HTML5 project in Netbeans.
4) Copy the code in my original post into an HTML file.
5) Run the code using the "Run" button. Make sure Google Chrome is selected as the web browser.

This error isn't consistently reproducible. Sometimes I get it when I perform the steps above, and sometimes I don't.
Back to top
vriha



Joined: 07 Feb 2013
Posts: 135

PostPosted: Wed Oct 14, 2015 10:48 am    Post subject: Javascript Crash When Checking For Undeclared Objects Reply with quote

Thank you,
I've tried it couple of times on Linux and on Mac, but no luck
reproducing. Maybe following [1] could help you. Either way, this
JavaScript code is evaluated by browser, not NetBeans.

[1]
http://stackoverflow.com/questions/24150713/why-does-typeof-only-sometimes-throw-referenceerror

Thank you,
Lada

On 14/10/15 03:44, TTCUSM wrote:
Quote:
Steps to reproduce:

1) Install Netbeans IDE, with the Google Chrome plugin.
2) Install Google Chrome, with the Netbeans extension.
3) Create a new HTML5 project in Netbeans.
4) Copy the code in my original post into an HTML file.
5) Run the code using the "Run" button. Make sure Google Chrome is selected as the web browser.

This error isn't consistently reproducible. Sometimes I get it when I perform the steps above, and sometimes I don't.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Web Client Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo