Aleks
asked on
Javascript syntax
I have the following javascript, but something in the syntax is wrong, perhaps someone who knows syntax can help. I get an error when running the ASP/Javascrip page on this lines:
<%
function isIPad() {
alert( Request.ServerVariables("H TTP_USER_A GENT") );
var isIpad = false;
alert( Request.ServerVariables("H TTP_USER_A GENT") );
if ( userAgent.indexOf("iPad") > 0 )
isIPad = true;
return isIpad;
}
%>
The code detects if the user is using an ipad or not.
<%
function isIPad() {
alert( Request.ServerVariables("H
var isIpad = false;
alert( Request.ServerVariables("H
if ( userAgent.indexOf("iPad") > 0 )
isIPad = true;
return isIpad;
}
%>
The code detects if the user is using an ipad or not.
http://scottrockers.com/blog/resources/simple-code-tricks/how-to-detect-ipad-and-redirect-to-ipad-version-website
ASKER
Thanks but I really don't know much of Javascript, what i do is display a region in the ASP based on user using ipad or not:
<%if ( isIPad() ) { %>
Code for text field here
<% } else { %>
Code for HTML editor here
<% } %>
... that being said what I need is to return 'isPad' value and not redirecting anywhere, so the javascript is quite different.
<%if ( isIPad() ) { %>
Code for text field here
<% } else { %>
Code for HTML editor here
<% } %>
... that being said what I need is to return 'isPad' value and not redirecting anywhere, so the javascript is quite different.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Got this error:
Microsoft JScript compilation error '800a03ee'
Expected ')'
/bluedot/Intranet/Cases/Co mmentspop/ AddComment s.asp, line 289
alert( "<%= Request.ServerVariables("H TTP_USER_A GENT")
Microsoft JScript compilation error '800a03ee'
Expected ')'
/bluedot/Intranet/Cases/Co
alert( "<%= Request.ServerVariables("H
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Seems like that worked, the second part of the code gave me an error though ... here it is:
<%if ( isIPad() ) { %>
<label for="Comments"></label>
<textarea name="Comments" cols="50" rows="8" id="Comments"><% if (!Lettrmrg.EOF || !Lettrmrg.BOF) { %> <%=(Lettrmrg.Fields.Item(" LtrBody"). Value)%> <% } // end !Lettrmrg.EOF || !Lettrmrg.BOF %>
</textarea>
<% } else { %>
<textarea id="Comments" name="Comments" class="dmxEditor" style="width:600px;height: 300px"><% if (!Lettrmrg.EOF || !Lettrmrg.BOF) { %> <%=(Lettrmrg.Fields.Item(" LtrBody"). Value)%> <% } // end !Lettrmrg.EOF || !Lettrmrg.BOF %>
</textarea>
<script type="text/javascript">
// <![CDATA[
jQuery(document).ready(
function()
{
jQuery("#Comments").dmxEdi tor(
{}
);
}
);
// ]]>
</script>
<% } %>
-- the error is in the first like of the code --
Microsoft JScript runtime error '800a138f'
Object expected
/bluedot/Intranet/Cases/Co mmentspop/ AddComment s.asp, line 506
-------
I didnt use to get an error on this part of the code ... maybe a naming is not the same as the first part of the code ?
<%if ( isIPad() ) { %>
<label for="Comments"></label>
<textarea name="Comments" cols="50" rows="8" id="Comments"><% if (!Lettrmrg.EOF || !Lettrmrg.BOF) { %> <%=(Lettrmrg.Fields.Item("
</textarea>
<% } else { %>
<textarea id="Comments" name="Comments" class="dmxEditor" style="width:600px;height:
</textarea>
<script type="text/javascript">
// <![CDATA[
jQuery(document).ready(
function()
{
jQuery("#Comments").dmxEdi
{}
);
}
);
// ]]>
</script>
<% } %>
-- the error is in the first like of the code --
Microsoft JScript runtime error '800a138f'
Object expected
/bluedot/Intranet/Cases/Co
-------
I didnt use to get an error on this part of the code ... maybe a naming is not the same as the first part of the code ?
ASKER
To keep things simple this is the bottom code that displays the region based on the value captured.
<%if ( isIPad() ) { %>
code for text region here
<% } else { %>
code for HTML editor here
<% } %>
<%if ( isIPad() ) { %>
I get the error above on line # 1. Seems like the value is not being captured ?
<%if ( isIPad() ) { %>
code for text region here
<% } else { %>
code for HTML editor here
<% } %>
<%if ( isIPad() ) { %>
I get the error above on line # 1. Seems like the value is not being captured ?
ASKER
As a matter of fact the logic that we should have in the javascript is the following:
Function isIPad()
If InStr(Request.ServerVariab les("HTTP_ USER_AGENT "), "iPad") > 0 Then
isIPad = True
Else
isIPad = False
End If
End Function
The above is VBscript though ... same logic but in javascript, i dont think the current logic is the same for:
<script type='text/javascript'>
function isIPad(){
var isIPad = false;
var userAgent = '<%=Request.ServerVariable s("HTTP_US ER_AGENT") %>';
alert(userAgent);
if(userAgent.indexOf("iPad ") > 0) isIPad = true;
return isIPad;
}
</script>
Function isIPad()
If InStr(Request.ServerVariab
isIPad = True
Else
isIPad = False
End If
End Function
The above is VBscript though ... same logic but in javascript, i dont think the current logic is the same for:
<script type='text/javascript'>
function isIPad(){
var isIPad = false;
var userAgent = '<%=Request.ServerVariable
alert(userAgent);
if(userAgent.indexOf("iPad
return isIPad;
}
</script>
ASKER
I also tried using vbscript code in the javascript page:
<script type="text/vbscript">
Function isIPad()
If InStr(Request.ServerVariab les("HTTP_ USER_AGENT "), "iPad") > 0 Then
isIPad = True
Else
isIPad = False
End If
End Function
</script>
then below ...
<%if ( isIPad() ) { %>
<label for="Comments"></label>
<textarea name="Comments" cols="50" rows="8" id="Comments"><% if (!Lettrmrg.EOF || !Lettrmrg.BOF) { %> <%=(Lettrmrg.Fields.Item(" LtrBody"). Value)%> <% } // end !Lettrmrg.EOF || !Lettrmrg.BOF %>
</textarea>
<% } else { %>
<textarea id="Comments" name="Comments" class="dmxEditor" style="width:600px;height: 300px"><% if (!Lettrmrg.EOF || !Lettrmrg.BOF) { %> <%=(Lettrmrg.Fields.Item(" LtrBody"). Value)%> <% } // end !Lettrmrg.EOF || !Lettrmrg.BOF %>
</textarea>
<script type="text/javascript">
// <![CDATA[
jQuery(document).ready(
function()
{
jQuery("#Comments").dmxEdi tor(
{}
);
}
);
// ]]>
</script>
<% } %>
Same error:
Microsoft JScript runtime error '800a138f'
Object expected
/bluedot/Intranet/Cases/Co mmentspop/ AddComment s.asp, line 510
<script type="text/vbscript">
Function isIPad()
If InStr(Request.ServerVariab
isIPad = True
Else
isIPad = False
End If
End Function
</script>
then below ...
<%if ( isIPad() ) { %>
<label for="Comments"></label>
<textarea name="Comments" cols="50" rows="8" id="Comments"><% if (!Lettrmrg.EOF || !Lettrmrg.BOF) { %> <%=(Lettrmrg.Fields.Item("
</textarea>
<% } else { %>
<textarea id="Comments" name="Comments" class="dmxEditor" style="width:600px;height:
</textarea>
<script type="text/javascript">
// <![CDATA[
jQuery(document).ready(
function()
{
jQuery("#Comments").dmxEdi
{}
);
}
);
// ]]>
</script>
<% } %>
Same error:
Microsoft JScript runtime error '800a138f'
Object expected
/bluedot/Intranet/Cases/Co
ASKER
If I get rid of the bottom code the page works fine with the javascript code at the top. So right now the bottom code is the issue. I will open a different ticket for this issue thanks for the javascript code help.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, so I used the code above it didnt give me an y errors on any of those lines, but below in the page i get this error (Part where i display content based on the above code)
This is the base code i use to display content:
<%if ( isIPad() ) { %>
code for text region here
<% } else { %>
code for HTML editor here
<% } %>
But it gives me this error:
Microsoft JScript runtime error '800a138f'
Object expected
/bluedot/Intranet/Cases/Co mmentspop/ AddComment s.asp, line 515
Anything i am missing ?
This is the base code i use to display content:
<%if ( isIPad() ) { %>
code for text region here
<% } else { %>
code for HTML editor here
<% } %>
But it gives me this error:
Microsoft JScript runtime error '800a138f'
Object expected
/bluedot/Intranet/Cases/Co
Anything i am missing ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.