PC Review


Reply
Thread Tools Rate Thread

determining whether a character exists in the address

 
 
=?Utf-8?B?WGVybw==?=
Guest
Posts: n/a
 
      9th Dec 2005
hello. i want to determine whether the percentage sign (%) exists in the
page's address, so i write this code:

<script language=javascript>
presentAdd = self.location
<!-- "self.location" cannot be replaced by the actual file name because it
will be employed in different pages -->
if (presentAdd.indexOf('%') > -1) {
document.write('present')
} else {
document.write('absent')
}
</script>

IE returns an error message "Object doesn't support this property or method".
What should be modified?
Thanks.

--
Xero

http://www.chezjeff.net
My personal web portal
 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      9th Dec 2005
if (document.location.href.indexOf('%') > -1) {
document.write('present')
} else {
document.write('absent')
}

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Xero" <jeff_at_chezjeff_dot_net> wrote in message
news:B7FC2A1D-BC02-4A15-8597-(E-Mail Removed)...
> hello. i want to determine whether the percentage sign (%) exists in the
> page's address, so i write this code:
>
> <script language=javascript>
> presentAdd = self.location
> <!-- "self.location" cannot be replaced by the actual file name because it
> will be employed in different pages -->
> if (presentAdd.indexOf('%') > -1) {
> document.write('present')
> } else {
> document.write('absent')
> }
> </script>
>
> IE returns an error message "Object doesn't support this property or
> method".
> What should be modified?
> Thanks.
>
> --
> Xero
>
> http://www.chezjeff.net
> My personal web portal



 
Reply With Quote
 
=?Utf-8?B?WGVybw==?=
Guest
Posts: n/a
 
      9th Dec 2005
got it, thanks so much!

--
Xero

http://www.chezjeff.net
My personal web portal


"Kevin Spencer" wrote:

> if (document.location.href.indexOf('%') > -1) {
> document.write('present')
> } else {
> document.write('absent')
> }
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> ..Net Developer
> You can lead a fish to a bicycle,
> but you can't make it stink.
>
> "Xero" <jeff_at_chezjeff_dot_net> wrote in message
> news:B7FC2A1D-BC02-4A15-8597-(E-Mail Removed)...
> > hello. i want to determine whether the percentage sign (%) exists in the
> > page's address, so i write this code:
> >
> > <script language=javascript>
> > presentAdd = self.location
> > <!-- "self.location" cannot be replaced by the actual file name because it
> > will be employed in different pages -->
> > if (presentAdd.indexOf('%') > -1) {
> > document.write('present')
> > } else {
> > document.write('absent')
> > }
> > </script>
> >
> > IE returns an error message "Object doesn't support this property or
> > method".
> > What should be modified?
> > Thanks.
> >
> > --
> > Xero
> >
> > http://www.chezjeff.net
> > My personal web portal

>
>
>

 
Reply With Quote
 
Jon Spivey
Guest
Posts: n/a
 
      9th Dec 2005
Kev's reply is good but if you want to learn javascript for future projects
doing it like this should help

document.write(location.href.indexOf("%")==-1? "absent":"present")

--
Cheers,
Jon
Microsoft MVP


"Xero" <jeff_at_chezjeff_dot_net> wrote in message
news:196AC45C-8305-471A-86C5-(E-Mail Removed)...
> got it, thanks so much!
>
> --
> Xero
>
> http://www.chezjeff.net
> My personal web portal
>
>
> "Kevin Spencer" wrote:
>
>> if (document.location.href.indexOf('%') > -1) {
>> document.write('present')
>> } else {
>> document.write('absent')
>> }
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> ..Net Developer
>> You can lead a fish to a bicycle,
>> but you can't make it stink.
>>
>> "Xero" <jeff_at_chezjeff_dot_net> wrote in message
>> news:B7FC2A1D-BC02-4A15-8597-(E-Mail Removed)...
>> > hello. i want to determine whether the percentage sign (%) exists in
>> > the
>> > page's address, so i write this code:
>> >
>> > <script language=javascript>
>> > presentAdd = self.location
>> > <!-- "self.location" cannot be replaced by the actual file name because
>> > it
>> > will be employed in different pages -->
>> > if (presentAdd.indexOf('%') > -1) {
>> > document.write('present')
>> > } else {
>> > document.write('absent')
>> > }
>> > </script>
>> >
>> > IE returns an error message "Object doesn't support this property or
>> > method".
>> > What should be modified?
>> > Thanks.
>> >
>> > --
>> > Xero
>> >
>> > http://www.chezjeff.net
>> > My personal web portal

>>
>>
>>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      9th Dec 2005
Definitely more succinct, Jon. And succint is good!

--

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Jon Spivey" <(E-Mail Removed)> wrote in message
news:%23Fo5WRO$(E-Mail Removed)...
> Kev's reply is good but if you want to learn javascript for future
> projects doing it like this should help
>
> document.write(location.href.indexOf("%")==-1? "absent":"present")
>
> --
> Cheers,
> Jon
> Microsoft MVP
>
>
> "Xero" <jeff_at_chezjeff_dot_net> wrote in message
> news:196AC45C-8305-471A-86C5-(E-Mail Removed)...
>> got it, thanks so much!
>>
>> --
>> Xero
>>
>> http://www.chezjeff.net
>> My personal web portal
>>
>>
>> "Kevin Spencer" wrote:
>>
>>> if (document.location.href.indexOf('%') > -1) {
>>> document.write('present')
>>> } else {
>>> document.write('absent')
>>> }
>>>
>>> --
>>> HTH,
>>>
>>> Kevin Spencer
>>> Microsoft MVP
>>> ..Net Developer
>>> You can lead a fish to a bicycle,
>>> but you can't make it stink.
>>>
>>> "Xero" <jeff_at_chezjeff_dot_net> wrote in message
>>> news:B7FC2A1D-BC02-4A15-8597-(E-Mail Removed)...
>>> > hello. i want to determine whether the percentage sign (%) exists in
>>> > the
>>> > page's address, so i write this code:
>>> >
>>> > <script language=javascript>
>>> > presentAdd = self.location
>>> > <!-- "self.location" cannot be replaced by the actual file name
>>> > because it
>>> > will be employed in different pages -->
>>> > if (presentAdd.indexOf('%') > -1) {
>>> > document.write('present')
>>> > } else {
>>> > document.write('absent')
>>> > }
>>> > </script>
>>> >
>>> > IE returns an error message "Object doesn't support this property or
>>> > method".
>>> > What should be modified?
>>> > Thanks.
>>> >
>>> > --
>>> > Xero
>>> >
>>> > http://www.chezjeff.net
>>> > My personal web portal
>>>
>>>
>>>

>
>



 
Reply With Quote
 
clintonG
Guest
Posts: n/a
 
      9th Dec 2005
Yea tell em' about the ternary operator a.k.a the conditional operator :-)

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:%23KomQeO$(E-Mail Removed)...
> Definitely more succinct, Jon. And succint is good!
>
> --
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> You can lead a fish to a bicycle,
> but you can't make it stink.
>
> "Jon Spivey" <(E-Mail Removed)> wrote in message
> news:%23Fo5WRO$(E-Mail Removed)...
>> Kev's reply is good but if you want to learn javascript for future
>> projects doing it like this should help
>>
>> document.write(location.href.indexOf("%")==-1? "absent":"present")
>>
>> --
>> Cheers,
>> Jon
>> Microsoft MVP
>>
>>
>> "Xero" <jeff_at_chezjeff_dot_net> wrote in message
>> news:196AC45C-8305-471A-86C5-(E-Mail Removed)...
>>> got it, thanks so much!
>>>
>>> --
>>> Xero
>>>
>>> http://www.chezjeff.net
>>> My personal web portal
>>>
>>>
>>> "Kevin Spencer" wrote:
>>>
>>>> if (document.location.href.indexOf('%') > -1) {
>>>> document.write('present')
>>>> } else {
>>>> document.write('absent')
>>>> }
>>>>
>>>> --
>>>> HTH,
>>>>
>>>> Kevin Spencer
>>>> Microsoft MVP
>>>> ..Net Developer
>>>> You can lead a fish to a bicycle,
>>>> but you can't make it stink.
>>>>
>>>> "Xero" <jeff_at_chezjeff_dot_net> wrote in message
>>>> news:B7FC2A1D-BC02-4A15-8597-(E-Mail Removed)...
>>>> > hello. i want to determine whether the percentage sign (%) exists in
>>>> > the
>>>> > page's address, so i write this code:
>>>> >
>>>> > <script language=javascript>
>>>> > presentAdd = self.location
>>>> > <!-- "self.location" cannot be replaced by the actual file name
>>>> > because it
>>>> > will be employed in different pages -->
>>>> > if (presentAdd.indexOf('%') > -1) {
>>>> > document.write('present')
>>>> > } else {
>>>> > document.write('absent')
>>>> > }
>>>> > </script>
>>>> >
>>>> > IE returns an error message "Object doesn't support this property or
>>>> > method".
>>>> > What should be modified?
>>>> > Thanks.
>>>> >
>>>> > --
>>>> > Xero
>>>> >
>>>> > http://www.chezjeff.net
>>>> > My personal web portal
>>>>
>>>>
>>>>

>>
>>

>
>



 
Reply With Quote
 
Trevor L.
Guest
Posts: n/a
 
      10th Dec 2005
Great ,
I like it too

Is it true that (condition) ? value2 : value2 can be used anywhere where one
would normally place value ?

I note that Jon's code does not even place the condition in ()
--
Cheers,
Trevor L. (retired system analyst/programmer - but not a web programmer )
Website: http://tandcl.homemail.com.au


clintonG wrote:
> Yea tell em' about the ternary operator a.k.a the conditional
> operator :-)
> <%= Clinton Gallagher
> METROmilwaukee (sm) "A Regional Information Service"
> NET csgallagher AT metromilwaukee.com
> URL http://metromilwaukee.com/
> URL http://clintongallagher.metromilwaukee.com/
>
>
> "Kevin Spencer" <(E-Mail Removed)> wrote in message
> news:%23KomQeO$(E-Mail Removed)...
>> Definitely more succinct, Jon. And succint is good!
>>
>> --
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> You can lead a fish to a bicycle,
>> but you can't make it stink.
>>
>> "Jon Spivey" <(E-Mail Removed)> wrote in message
>> news:%23Fo5WRO$(E-Mail Removed)...
>>> Kev's reply is good but if you want to learn javascript for future
>>> projects doing it like this should help
>>>
>>> document.write(location.href.indexOf("%")==-1? "absent":"present")
>>>
>>> --
>>> Cheers,
>>> Jon
>>> Microsoft MVP
>>>
>>>
>>> "Xero" <jeff_at_chezjeff_dot_net> wrote in message
>>> news:196AC45C-8305-471A-86C5-(E-Mail Removed)...
>>>> got it, thanks so much!
>>>>
>>>> --
>>>> Xero
>>>>
>>>> http://www.chezjeff.net
>>>> My personal web portal
>>>>
>>>>
>>>> "Kevin Spencer" wrote:
>>>>
>>>>> if (document.location.href.indexOf('%') > -1) {
>>>>> document.write('present')
>>>>> } else {
>>>>> document.write('absent')
>>>>> }
>>>>>
>>>>> --
>>>>> HTH,
>>>>>
>>>>> Kevin Spencer
>>>>> Microsoft MVP
>>>>> ..Net Developer
>>>>> You can lead a fish to a bicycle,
>>>>> but you can't make it stink.
>>>>>
>>>>> "Xero" <jeff_at_chezjeff_dot_net> wrote in message
>>>>> news:B7FC2A1D-BC02-4A15-8597-(E-Mail Removed)...
>>>>>> hello. i want to determine whether the percentage sign (%)
>>>>>> exists in the
>>>>>> page's address, so i write this code:
>>>>>>
>>>>>> <script language=javascript>
>>>>>> presentAdd = self.location
>>>>>> <!-- "self.location" cannot be replaced by the actual file name
>>>>>> because it
>>>>>> will be employed in different pages -->
>>>>>> if (presentAdd.indexOf('%') > -1) {
>>>>>> document.write('present')
>>>>>> } else {
>>>>>> document.write('absent')
>>>>>> }
>>>>>> </script>
>>>>>>
>>>>>> IE returns an error message "Object doesn't support this
>>>>>> property or method".
>>>>>> What should be modified?
>>>>>> Thanks.
>>>>>>
>>>>>> --
>>>>>> Xero
>>>>>>
>>>>>> http://www.chezjeff.net
>>>>>> My personal web portal



 
Reply With Quote
 
Jon Spivey
Guest
Posts: n/a
 
      10th Dec 2005
Yes, you can use it like this
var a = 10
b=(a==10)?20:30;
// brackets are optional this would be equally valid
b=a==10?20:30;
//b =20
// or
alert(a==10?'It\'s ten':'It\'s not ten')


--
Cheers,
Jon
Microsoft MVP

"Trevor L." <(E-Mail Removed)> wrote in message
news:uC%23JVwT$(E-Mail Removed)...
> Great ,
> I like it too
>
> Is it true that (condition) ? value2 : value2 can be used anywhere where
> one would normally place value ?
>
> I note that Jon's code does not even place the condition in ()
> --
> Cheers,
> Trevor L. (retired system analyst/programmer - but not a web programmer )
> Website: http://tandcl.homemail.com.au
>
>
> clintonG wrote:
>> Yea tell em' about the ternary operator a.k.a the conditional
>> operator :-)
>> <%= Clinton Gallagher
>> METROmilwaukee (sm) "A Regional Information Service"
>> NET csgallagher AT metromilwaukee.com
>> URL http://metromilwaukee.com/
>> URL http://clintongallagher.metromilwaukee.com/
>>
>>
>> "Kevin Spencer" <(E-Mail Removed)> wrote in message
>> news:%23KomQeO$(E-Mail Removed)...
>>> Definitely more succinct, Jon. And succint is good!
>>>
>>> --
>>>
>>> Kevin Spencer
>>> Microsoft MVP
>>> .Net Developer
>>> You can lead a fish to a bicycle,
>>> but you can't make it stink.
>>>
>>> "Jon Spivey" <(E-Mail Removed)> wrote in message
>>> news:%23Fo5WRO$(E-Mail Removed)...
>>>> Kev's reply is good but if you want to learn javascript for future
>>>> projects doing it like this should help
>>>>
>>>> document.write(location.href.indexOf("%")==-1? "absent":"present")
>>>>
>>>> --
>>>> Cheers,
>>>> Jon
>>>> Microsoft MVP
>>>>
>>>>
>>>> "Xero" <jeff_at_chezjeff_dot_net> wrote in message
>>>> news:196AC45C-8305-471A-86C5-(E-Mail Removed)...
>>>>> got it, thanks so much!
>>>>>
>>>>> --
>>>>> Xero
>>>>>
>>>>> http://www.chezjeff.net
>>>>> My personal web portal
>>>>>
>>>>>
>>>>> "Kevin Spencer" wrote:
>>>>>
>>>>>> if (document.location.href.indexOf('%') > -1) {
>>>>>> document.write('present')
>>>>>> } else {
>>>>>> document.write('absent')
>>>>>> }
>>>>>>
>>>>>> --
>>>>>> HTH,
>>>>>>
>>>>>> Kevin Spencer
>>>>>> Microsoft MVP
>>>>>> ..Net Developer
>>>>>> You can lead a fish to a bicycle,
>>>>>> but you can't make it stink.
>>>>>>
>>>>>> "Xero" <jeff_at_chezjeff_dot_net> wrote in message
>>>>>> news:B7FC2A1D-BC02-4A15-8597-(E-Mail Removed)...
>>>>>>> hello. i want to determine whether the percentage sign (%)
>>>>>>> exists in the
>>>>>>> page's address, so i write this code:
>>>>>>>
>>>>>>> <script language=javascript>
>>>>>>> presentAdd = self.location
>>>>>>> <!-- "self.location" cannot be replaced by the actual file name
>>>>>>> because it
>>>>>>> will be employed in different pages -->
>>>>>>> if (presentAdd.indexOf('%') > -1) {
>>>>>>> document.write('present')
>>>>>>> } else {
>>>>>>> document.write('absent')
>>>>>>> }
>>>>>>> </script>
>>>>>>>
>>>>>>> IE returns an error message "Object doesn't support this
>>>>>>> property or method".
>>>>>>> What should be modified?
>>>>>>> Thanks.
>>>>>>>
>>>>>>> --
>>>>>>> Xero
>>>>>>>
>>>>>>> http://www.chezjeff.net
>>>>>>> My personal web portal

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining if a locale exists Jude Microsoft ASP .NET 0 27th Jun 2007 06:29 PM
Determining if a value already exists in column(s) =?Utf-8?B?Um9va2llX1VzZXI=?= Microsoft Excel Misc 0 3rd Oct 2006 05:32 PM
Determining Whether File Exists =?Utf-8?B?TWFnbml2eQ==?= Microsoft Excel Programming 9 8th Jun 2006 04:51 AM
Determining if a value exists in a column Lord MJ Microsoft Excel Discussion 2 24th Aug 2005 11:27 PM
Determining if a Table Exists Don Microsoft Access Form Coding 3 3rd Apr 2005 09:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:00 AM.