开发者

Why isn't this script working?

开发者 https://www.devze.com 2023-03-19 23:40 出处:网络
I put this into Notepad and saved as an htm.However, when I open it in IE, it just says the text without the <HEAD> and </HEAD>.I have tried encoding it as Unicode, UTF-8, Unicode bi开发者

I put this into Notepad and saved as an htm. However, when I open it in IE, it just says the text without the <HEAD> and </HEAD>. I have tried encoding it as Unicode, UTF-8, Unicode bi开发者_如何学JAVAg Endian, and ANSI.:

<HEAD>
var ifbumper=0
if (ifbumper=0)
  {
  window.location='/bumper?url=whatever'
  }
</HEAD>


You're writing JavaScript code, you need to put it inside of <script> tags. You also need to use == instead of = to compare values, and it's a good idea to put a ; following a line of code.

<HTML>
<HEAD>
<SCRIPT>
    var ifbumper=0;
    if (ifbumper==0)
    {
        window.location='/bumper?url=whatever';
    }
</SCRIPT>
</HEAD>


You need to wrap JavaScript code inside <script> tags like this:

<head>
    <script type="text/javascript">
        var ifbumper = 0;
        if (ifbumper == 0){
            window.location='/bumper?url=whatever';
        }
     </script>
</head>


The equality operator is ==, not just =. Your if should be aif (ifbumper == 0)

0

精彩评论

暂无评论...
验证码 换一张
取 消