javascript - jQuery 重定向到 div 类名称页面 (IframeTracker.js)

标签 javascript jquery redirect

我使用 IframeTracker jQuery 脚本,当单击具有 iframe 类 id 的 iframe 元素时会发出什么警报。我想在单击时重定向到 page.php?id=(div_class) 。我有这个代码:

jQuery(document).ready(function($){

    // Other iframes (wrapped with .iframetrack)
    $('.iframetrack iframe').iframeTracker({
        blurCallback: function(){

            $('<div class="alert alert-info">').html('Click on iframe : #' + this._overId).appendTo('#consoleDebug').delay(3000).fadeOut();

            window.setTimeout(function() {
             window.location.href = 'page.php?id=' + this._overId;
            }, 4000);

        },
        overCallback: function(element){
            this._overId = $(element).parents('.iframetrack').attr('id'); // Saving the iframe wrapper id
        },
        outCallback: function(element){
            this._overId = null; // Reset hover iframe wrapper id
        },
        _overId: null
    });

});

它重定向但没有 div 类名到 page.php?id=undefined 我认为“this._overId”是 div 的类名,但不起作用。

如何在重定向 id 中使用单击的 div 类名? (page.php?id=(clicked_div_class))

最佳答案

怎么样:

$("div").click(
    function(){
    var id=this.className;
    window.location.href = 'page.php?id=' + id;
})

关于javascript - jQuery 重定向到 div 类名称页面 (IframeTracker.js),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37749884/

相关文章:

Javascript 调用和应用函数只在第一个参数上调用?

javascript - 将 php 正则表达式转换为 javascript

javascript - 加载大量图像

Jquery ui拖放droppable "drop"事件

angularjs - 在 firebase 中使用 $location.path() 进行重定向

JavaScript 命名空间模式

javascript - Nodejs 不同文件中的函数列表

javascript - 为什么名为 'index.js' 的 JavaScript 文件在 Django 模板中不起作用?

android - 我如何处理这个字符串来打开我的应用程序

redirect - 主页重定向会影响搜索引擎抓取吗?