将php文件链接到HTML文件?

时间:2013-06-12 12:22:22

标签: php html hyperlink

在这个网站上http://www.flatness.eu/test.html我有一个php文件的链接。

该文件包含一个用php编写的艺术作品。

该页面包含用户单击以逐页删除的图像层,直到页面为空。

是否有可能最后一次点击php文件链接用户直接回到他们开始的html主页?

4 个答案:

答案 0 :(得分:6)

您链接到的php文件正在使用jQuery将一个名为houdini的类添加到隐藏的图像中。您可以更改单击处理程序以计算类不是houdini的图像数量,然后重定向用户。

$(function() {                       //run when the DOM is ready
    $(".image").click(function() {     //use a class, since your ID gets mangled
      $(this).addClass("houdini");     //add the class to the clicked element

      if( $('.image:not(.houdini)').length == 1 )
      {
          // this is the last image, redirect user
          window.location = 'http://yourpageurl.com';
      }
    });
  });

答案 1 :(得分:2)

PHP是服务器端 - 如果您不是每次点击都与服务器通信,它就无法知道用户何时点击了最后一张图片。

在你的代码中你通过jquery将类添加到css来隐藏图片,你可以用$('。houdini')来计算该类有多少个元素。长度并根据你可以通过javascript调用重定向:window .location =“URL_HERE”;

更容易计算倒数 - 所以你可以先让所有图像都有一些类似'显示',然后点击执行:

$(".image").on('click',function() {
  $(this)addClass('houdini').removeClass('shown');
  if ($('shown').length == 0) {
    window.location = 'http://www.flatness.eu/home.html';
  }
});

答案 2 :(得分:0)

PHP中的

:空时触发:

<?php
header("Location: http://www.example.com/");
exit;
?>

编辑: 你实际上用js删除图片,所以重新加载也应该由js触发!

  $(function() {                       //run when the DOM is ready
    $(".image").click(function() {     //use a class, since your ID gets mangled
      $(this).addClass("houdini");     //add the class to the clicked element
            if($('.houdini').length == $(".image").length)
            {
            window.location.href="http://www.example.com/";
            }  
        });
     });

答案 3 :(得分:0)

链接html代码..

我猜你已经用HTML编写了所有代码,然后你只需将PHP代码与HTML代码混合。

<?php
  //your php code
 ?>

或在页面中提供表单操作,以提供主文件的路径。