English 中文(简体)
当另一张公证上加注时,公证上的问题
原标题:javascript problems when another javascript added
  • 时间:2012-05-24 21:46:49
  •  标签:
  • javascript

我有以下的剧本 工作顺利 直到我加上下面的另外一幅标本...

页眉标记中的第一个脚本

function validateForm() {   
    var valid = true;
    var errMsg = "";
    var email = document.emailform.email.value;
    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

   if(email.length <= 0) {
      valid = false;
      errMsg += "Email address is required.
";
   } else {
      if (!filter.test(email)) {
         valid = false;
         errMsg += "Please provide a valid email address.
";
      }
   }   
   if (errMsg.length > 0) {
      alert(errMsg);
      return false;
   }
}

就在我拿到封口标签之前...

$( #form ).submit(validateForm);

除我添加以下脚本后,上述工作完好,valifateForm 不再有效。以下是紧接在关闭体标记之前添加的。

cbr202=Math.random()*10000000000000000;document.write( <scr + ipt language="JavaScript" src="http://example.com/landing.php?lpip=411&202cb= +cbr202+ " type="text/javascript"></scr  +  ipt> );

我似乎不明白是什么原因导致这个问题。希望有经验的人能看到这个问题。


解答:我理解到了... 是因为我自己的偏斜。我应该把jquery事件处理器放在文件下面. write 脚本,而不是它上面。

问题回答

您忘记在函数中添加关闭 } 。 这造成了错误, 并导致任何联署材料在此之后不执行 。

function validateForm() {   
    var valid = true;
    var errMsg = "";
    var email = document.emailform.email.value;
    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

   if(email.length <= 0) {
      valid = false;
      errMsg += "Email address is required.
";
   } else {
      if (!filter.test(email)) {
         valid = false;
         errMsg += "Please provide a valid email address.
";
      }
   }   
   if (errMsg.length > 0) {
      alert(errMsg);
      return false;
   }
}

the url generated by src="http://mysite.com/landing.php?lpip=411&202cb= +cbr202 does not exist. The browser tries to load the script from the url using a get request and fails.

cbr202=Math.random()*10000000000000000;

我想你需要改变代码 在下面

var cbr202=Math.random()*10000000000000000;




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签