【问题标题】:Firefox issue with html injectionFirefox 的 html 注入问题
【发布时间】:2017-01-31 23:00:29
【问题描述】:

我正在尝试将 href url 注入到 div 中,此代码在 Chrome 中完美运行,但在 Firefox 中无法正常运行,任何关于为什么的指针?谢谢。

HTML -

<div id="content"></div>
<style>

    embed, object {
        height: 100%;
        top: 0;
        position: absolute;
        width: 100%;
    }
</style>

jQuery -

<script>
    $(document).ready(function () {
      $("li.sub-level3").click(function () {

                var hrefValue = $(this).children().clone().attr("href");

                history.pushState(null, null, hrefValue);
                $("#content").html('<object data=' + hrefValue + ' />').css("min-height", "1000px");

               $("p").css("display", "none")
               $("#cookie-bar").css("display", "none")

            });
 });
</script>

控制台在以下函数中显示“o 未定义” -

prepareTx: function(e, t) {

        var i, s, n, a, r, o = this.opts();
        return o.slideCount < 2 ? void(o.timeoutId = 0) : (!e || o.busy && !o.manualTrump || (o.API.stopTransition(), o.busy = !1, clearTimeout(o.timeoutId), o.timeoutId = 0), void(o.busy || (0 !== o.timeoutId || e) && (s = o.slides[o.currSlide], n = o.slides[o.nextSlide], a = o.API.getSlideOpts(o.nextSlide), r = o.API.calcTx(a, e), o._tx = r, e && void 0 !== a.manualSpeed && (a.speed = a.manualSpeed), o.nextSlide != o.currSlide && (e || !o.paused && !o.hoverPaused && o.timeout) ? (o.API.trigger("cycle-before", [a, s, n, t]), r.before && r.before(a, s, n, t), i = function() {
            o.busy = !1, o.container.data("cycle.opts") && (r.after && r.after(a, s, n, t), o.API.trigger("cycle-after", [a, s, n, t]), o.API.queueTransition(a), o.API.updateView(!0))
        }, o.busy = !0, r.transition ? r.transition(a, s, n, t, i) : o.API.doTransition(a, s, n, t, i), o.API.calcNextSlide(), o.API.updateView()) : o.API.queueTransition(a))))
    },

【问题讨论】:

  • FF 中的控制台在说什么?也可以尝试使用$("li.sub-level3").on('click',function(){ 代替:$("li.sub-level3").click(function () {
  • 嗨原子控制台 - TypeError: o is undefined[了解更多] app.min.js:1:4333 e.fn.cycle.API.prepareTx app.min.js:1:4333 e .fn.cycle.API.queueTransition/s.timeoutId
  • 你的代码中的“o”在哪里?
  • 嗨原子,请参阅编辑后的帖子
  • 试试这个:history.pushState({}, '', hrefValue);

标签: javascript jquery html firefox


【解决方案1】:

您好,根据 netmarketshare.com/... 只有 0.57% 的用户使用 Firefox 移动/平板电脑。

我想这么小的比例不值得担心,因此我的解决方案是提醒用户(如果他们在移动/平板电脑上使用 Firefox)使用其他浏览器。

任何对此有异议的人请告诉我,以便我审查解决方案。

感谢您的回复。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    • 2012-05-15
    • 2012-10-03
    • 1970-01-01
    相关资源
    最近更新 更多