473,396 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What am I doing wrong here. Simple statement. Novice Question.

HI! I get an error with this code.

<SCRIPT language="JavaScript">
If (ifp==""){
ifp="default.htm"}
//--></SCRIPT>

Basicly I want my iframe to have a default page if the user enters in
directly. so I need a way doing this. so I check to see if the ifp value is
null and if so then assign it a value. is this correct?
Thanks in advance :)

Paul
Jul 23 '05 #1
6 3285
"Paul" <pa***********@sympatico.ca> wrote in message
news:uL*******************@news20.bellglobal.com.. .
HI! I get an error with this code.

<SCRIPT language="JavaScript">
If (ifp==""){
ifp="default.htm"}
//--></SCRIPT>

Basicly I want my iframe to have a default page if the user enters in
directly. so I need a way doing this. so I check to see if the ifp value is
null and if so then assign it a value. is this correct?
Thanks in advance :)

Paul

As you don't state the error I may wrong but if, as I expect, it is "object
expected" then it's because you have a capital "I" in "If" which should be
lowercase:

if (ifp == "")
{
ifp = "default.htm";
}

In general all JavaScript keywords start with lowercase letters, built-in
objects such as "String" are one such exception, and usually if two or more
words are concatenated all but the first have an uppercase first letter, e.g
"toLowerCase". An exception to this are the operators such as "typeof".
--
As a side point, although in this instance the syntax is the same, Java and
JavaScript are two different beasts and I suggest restricting your choice of
groups to the relevant ones.

Joe (MVP)

https://mvp.support.microsoft.com/pr...8-8741D22D17A5

Jul 23 '05 #2
Paul wrote:
<SCRIPT language="JavaScript">
If (ifp==""){
ifp="default.htm"}
//--></SCRIPT> <snip> ... . so I check to see if the ifp
value is null ...

<snip>

The algorithm for the type-converting comparison operator - == - (ECMA
262 3rd edition; section 11.9.3) does not allow any string value
(including the empty string) to equal null. So whatever you are
attempting you are not seeing if ifp is null.

Richard.
Jul 23 '05 #3
HI! thanks, I saw that little one after I posted it. but there is still a
problem. and the other post answered that one.

Do you know of another way to do it. ( other than converting the string and
then back again )?

Thanks in advance :)

Paul
"Joe Fawcett" <jo********@newsgroups.nospam> wrote in message
news:uE**************@tk2msftngp13.phx.gbl...
"Paul" <pa***********@sympatico.ca> wrote in message
news:uL*******************@news20.bellglobal.com.. .
HI! I get an error with this code.

<SCRIPT language="JavaScript">
If (ifp==""){
ifp="default.htm"}
//--></SCRIPT>

Basicly I want my iframe to have a default page if the user enters in
directly. so I need a way doing this. so I check to see if the ifp value
is null and if so then assign it a value. is this correct?
Thanks in advance :)

Paul

As you don't state the error I may wrong but if, as I expect, it is
"object expected" then it's because you have a capital "I" in "If" which
should be lowercase:

if (ifp == "")
{
ifp = "default.htm";
}

In general all JavaScript keywords start with lowercase letters, built-in
objects such as "String" are one such exception, and usually if two or
more words are concatenated all but the first have an uppercase first
letter, e.g "toLowerCase". An exception to this are the operators such as
"typeof".
--
As a side point, although in this instance the syntax is the same, Java
and JavaScript are two different beasts and I suggest restricting your
choice of groups to the relevant ones.

Joe (MVP)

https://mvp.support.microsoft.com/pr...8-8741D22D17A5

Jul 23 '05 #4
"Paul" <pa***********@sympatico.ca> wrote in message
news:eh*************@TK2MSFTNGP15.phx.gbl...
HI! thanks, I saw that little one after I posted it. but there is still a
problem. and the other post answered that one.

Do you know of another way to do it. ( other than converting the string and
then back again )?

Thanks in advance :)

Paul

I'm not sure, if you want to test for null or empty string the have:
if (!ifp)
{
//ifp is null or empty
}
--

Joe (MVP)

https://mvp.support.microsoft.com/pr...8-8741D22D17A5
Jul 24 '05 #5
Paul wrote:
HI! I get an error with this code.

<SCRIPT language="JavaScript">
If (ifp==""){
ifp="default.htm"}
//--></SCRIPT>

Basicly I want my iframe to have a default page if the user enters in
directly. so I need a way doing this. so I check to see if the ifp value is
null and if so then assign it a value. is this correct?


comp.lang.javascript
Aug 9 '05 #6
Hmm!

There have been a few posts on this topic (or related), including some I
have taken part in

One spelt out the different between:
a null string, tested by 'if (string == null)'
an empty string, tested by 'if (string == "")'
and
a string comprising a space, tested by 'if (string == " ")'

Your test is for an empty string. Is this what it should be?

You are testing if (ifp == ..). I have not used iframes, so I don't know
whether this is the correct thing to be testing. Others may answer this.

With frames, I use this code
if (parent.location.href == window.location.href)
parent.location.href = "index.html"

I would need to experiment to see what works with iframes. (Maybe I should,
to add to my knowledge !)
--
Cheers,
Trevor L.
Website: http://tandcl.homemail.com.au

akarl wrote:
Paul wrote:
HI! I get an error with this code.

<SCRIPT language="JavaScript">
If (ifp==""){
ifp="default.htm"}
//--></SCRIPT>

Basicly I want my iframe to have a default page if the user enters in
directly. so I need a way doing this. so I check to see if the ifp
value is null and if so then assign it a value. is this correct?


comp.lang.javascript

Aug 9 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
5
by: Marian | last post by:
Hi, I am totaly novice in .NET and I am studying a book about this. There was mentioned "assembly". I did not understand, how function does it has . I would like to know the exact run of code...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
17
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

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.