AJAX/DHTML/灯箱

发布于 2024-08-18 15:29:14 字数 2081 浏览 9 评论 0原文

这是我的 js 代码,

<script type='text/javascript'>

  // Browser safe opacity handling function

  function setOpacity( value ) {
   document.getElementById("popup").style.opacity = value / 10;
   document.getElementById("popup").style.filter = 'alpha(opacity=' + value * 10 + ')';
  }

  function fadeInMyPopup() {
   for( var i = 0 ; i <= 100 ; i++ )
    setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
  }

  function fadeOutMyPopup() {
   for( var i = 0 ; i <= 100 ; i++ ) {
    setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
   }

   setTimeout('closeMyPopup()', 800 );
  }

  function closeMyPopup() {
   document.getElementById("popup").style.display = "none"
  }

  function fireMyPopup() {
   setOpacity( 0 );
   document.getElementById("popup").style.display = "block";
   fadeInMyPopup();
  }
  </script>

该代码工作正常。我正在使用此代码弹出一个用于向朋友发送电子邮件的灯箱。我所遇到的问题是,一旦我提交了,我会在同一个弹出窗口中说谢谢。 现在我要表达的感谢是这样的:这将进入一个新窗口。但我希望它在同一个灯箱窗口上。

<SCRIPT language="JavaScript">
<!--
window.location="thanks.php";
//-->
</SCRIPT>

这是我在其他代码中调用我的灯箱的方式:

<div id="popup" name="popup"><?php include ("email.php"); ?></div>

实现此目的的任何想法。 非常感谢。


好的,这里有更多解释

,我有 3 个事件需要调用一个表单:

在我的表单中,我使用图像作为提交按钮。 因此,要传递提交的值,这就是我所做的,它在所有浏览器中都可以正常工作:

< input type="image" onclick="this.form.select.value = this.value" >

现在我想在提交表单后调用另一个事件。

< input type="image" onclick="this.form.select.value = this.value; javascript:thanks()" >

现在,当我放入第二个事件时,我的表单不会验证或提交值。

当我将该事件放置在表单标记中时,它也不起作用。

这是我的 感谢() 的 js 函数: 函数感谢() { 设置不透明度(0); document.getElementById("popup").innerHTML = "谢谢!!" 关闭MyPopup();

    }

我正在使用此链接中的代码: http://dhtmlpopups.webarticles.org/fade-effects .php; 我有一个淡入淡出效果的注册表,提交表单后,我希望出现感谢信息,但它似乎效果不佳。

here is my js code

<script type='text/javascript'>

  // Browser safe opacity handling function

  function setOpacity( value ) {
   document.getElementById("popup").style.opacity = value / 10;
   document.getElementById("popup").style.filter = 'alpha(opacity=' + value * 10 + ')';
  }

  function fadeInMyPopup() {
   for( var i = 0 ; i <= 100 ; i++ )
    setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
  }

  function fadeOutMyPopup() {
   for( var i = 0 ; i <= 100 ; i++ ) {
    setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
   }

   setTimeout('closeMyPopup()', 800 );
  }

  function closeMyPopup() {
   document.getElementById("popup").style.display = "none"
  }

  function fireMyPopup() {
   setOpacity( 0 );
   document.getElementById("popup").style.display = "block";
   fadeInMyPopup();
  }
  </script>

this code works fine. i am using this code to pop-up a light box for emailing friends. what i am stuck with, once i submit the i will like to say thank you on the same pop-up.
right now here is how i am saying thank you: this goes to a new window. but i want it on the same light box window.

<SCRIPT language="JavaScript">
<!--
window.location="thanks.php";
//-->
</SCRIPT>

here is how i call my light box in my other code:

<div id="popup" name="popup"><?php include ("email.php"); ?></div>

any ideas on achieving this.
many thanks.


ok here is more explanation

I have 3 events that i want ro call for one form:

in my form, i am using an image for the submit button.
so to pass the value of the submit, here is what i do and it works fine in all browsers:

< input type="image" onclick="this.form.select.value = this.value" >

now i want to call another events, after the form has been submitted.

< input type="image" onclick="this.form.select.value = this.value; javascript:thanks()" >

now when i put the second event in, my form doesnt validate or submit the values.

and when i placed that event in the form tag, it doesnt work either.

here is my js function for thanks():
function thanks()
{
setOpacity( 0 );
document.getElementById("popup").innerHTML = "Thank You!!"
closeMyPopup();

    }

i am using the code from this link: http://dhtmlpopups.webarticles.org/fade-effects.php;
i have a registration form for the fade effects, and once the form get submitted, i want a thank-you to appear, but it doesnt seem to be working well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

堇年纸鸢 2024-08-25 15:29:14

我强烈建议您查看 jQuery 框架。它使得做这样的事情变得非常轻松。

您还可以使用 Javascript 中的innerHTML 属性来更新文本:

document.getElementById("popup").innerHTML = "Thanks, yo"

I'd strongly recommend checking out the jQuery framework. It makes doing things like this very painless.

You could also use the innerHTML property in Javascript to update the text:

document.getElementById("popup").innerHTML = "Thanks, yo"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文