I am having problem with following code. Its showing compliation error:- "Identifier Expected".
<script type="text/javascript" runat = "server">
function isOverElement(currentElement, targetId)
{
while (currentElement)
{
if (currentElement.id == targetId)
return currentElement;
currentElement = currentElement.parentNode;
}
return null;
}
</script>
The problem is in line:- function isOverElement(currentElement, targetId) Rest all is OK, I suppose.
please help. thnx
Remove the runat="server"
attribute from your <script>
tag. Javascript runs on the client, not on the server:
<script type="text/javascript">
function isOverElement(currentElement, targetId) {
while (currentElement) {
if (currentElement.id == targetId)
return currentElement;
currentElement = currentElement.parentNode;
}
return null;
}
</script>
You don't need runat="server" for script tag. Try removing the runat and see if it working
Please remove the tag runat="server" since you have written a pure javascript function.
Change
<script type="text/javascript" runat = "server"> to <script type="text/javascript">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.