2 weixin 39178685 weixin_39178685 于 2018.01.10 15:06 提问

JS 怎么写仿淘宝京东上拉详情页面 下拉返回上个页面

JS 怎么写淘宝上拉详情页面 下拉返回上个页面 如果有写过的 请联系我QQ648567422 谢谢了。讲一下思路也行

2个回答

showbo
showbo   Ds   Rxr 2018.01.10 22:02
已采纳
showbo
showbo 回复weixin_39178685: 代码呢?touchStart阻止默认事件,参考这个:http://www.w3dev.cn/article/20150911/web-page-open-in-wechat-forbidden-touce-down-display-black-background.aspx
5 个月之前 回复
weixin_39178685
weixin_39178685 安卓 的QQ浏览器X5内核 下拉返回 冲突了 回不去 。。。苹果上是好的
5 个月之前 回复
devmiao
devmiao 这个人说得是对的,那个贴代码贴的都是什么乱七八糟的?
5 个月之前 回复
u012514254
u012514254   2018.01.10 15:10

/* @license

  • jQuery.print, version 1.3.2
  • (c) Sathvik Ponangi, Doers' Guild
  • Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
    --------------------------------------------------------------------------/
    (function ($) {
    "use strict";
    // A nice closure for our definitions
    function getjQueryObject(string) {
    // Make string a vaild jQuery thing
    var jqObj = $("");
    try {
    jqObj = $(string)
    .clone();
    } catch (e) {
    jqObj = $("")
    .html(string);
    }
    return jqObj;
    }

    function printFrame(frameWindow) {
    // Print the selected window/iframe
    var def = $.Deferred();
    try {
    setTimeout(function () {
    // Fix for IE : Allow it to render the iframe
    frameWindow.focus();
    try {
    // Fix for IE11 - printng the whole page instead of the iframe content
    if (!frameWindow.document.execCommand('print', false, null)) {
    // document.execCommand returns false if it failed -http://stackoverflow.com/a/21336448/937891
    frameWindow.print();
    }
    } catch (e) {
    frameWindow.print();
    }
    frameWindow.close();
    def.resolve();
    }, 250);
    } catch (err) {
    def.reject(err);
    }
    return def;
    }

    function printContentInNewWindow(content) {
    // Open a new window and print selected content
    var w = window.open();
    w.document.write(content);
    w.document.close();
    return printFrame(w);
    }

    function isNode(o) {
    /* http://stackoverflow.com/a/384380/937891 */
    return !!(typeof Node === "object" ? o instanceof Node : o && typeof o === "object" && typeof o.nodeType === "number" && typeof o.nodeName === "string");
    }
    $.print = $.fn.print = function () {
    // Print a given set of elements
    var options, $this, self = this;
    // console.log("Printing", this, arguments);
    if (self instanceof $) {
    // Get the node if it is a jQuery object
    self = self.get(0);
    }
    if (isNode(self)) {
    // If this is a HTML element, i.e. for
    // $(selector).print()
    $this = $(self);
    if (arguments.length > 0) {
    options = arguments[0];
    }
    } else {
    if (arguments.length > 0) {
    // $.print(selector,options)
    $this = $(arguments[0]);
    if (isNode($this[0])) {
    if (arguments.length > 1) {
    options = arguments[1];
    }
    } else {
    // $.print(options)
    options = arguments[0];
    $this = $("html");
    }
    } else {
    // $.print()
    $this = $("html");
    }
    }
    // Default options
    var defaults = {
    globalStyles: true,
    mediaPrint: false,
    stylesheet: null,
    noPrintSelector: ".no-print",
    iframe: true,
    append: null,
    prepend: null,
    manuallyCopyFormValues: true,
    deferred: $.Deferred()
    };
    // Merge with user-options
    options = $.extend({}, defaults, (options || {}));
    var $styles = $("");
    if (options.globalStyles) {
    // Apply the stlyes from the current sheet to the printed page
    $styles = $("style, link, meta, title");
    } else if (options.mediaPrint) {
    // Apply the media-print stylesheet
    $styles = $("link[media=print]");
    }
    if (options.stylesheet) {
    // Add a custom stylesheet if given
    $styles = $.merge($styles, $(''));
    }
    // Create a copy of the element to print
    var copy = $this.clone();
    // Wrap it in a span to get the HTML markup string
    copy = $("")
    .append(copy);
    // Remove unwanted elements
    copy.find(options.noPrintSelector)
    .remove();
    // Add in the styles
    copy.append($styles.clone());
    // Appedned content
    copy.append(getjQueryObject(options.append));
    // Prepended content
    copy.prepend(getjQueryObject(options.prepend));
    if (options.manuallyCopyFormValues) {
    // Manually copy form values into the HTML for printing user-modified input fields
    // http://stackoverflow.com/a/26707753
    copy.find("input")
    .each(function () {
    var $field = $(this);
    if ($field.is("[type='radio']") || $field.is("[type='checkbox']")) {
    if ($field.prop("checked")) {
    $field.attr("checked", "checked");
    }
    } else {
    $field.attr("value", $field.val());
    }
    });
    copy.find("select").each(function () {
    var $field = $(this);
    $field.find(":selected").attr("selected", "selected");
    });
    copy.find("textarea").each(function () {
    // Fix for https://github.com/DoersGuild/jQuery.print/issues/18#issuecomment-96451589
    var $field = $(this);
    $field.text($field.val());
    });
    }
    // Get the HTML markup string
    var content = copy.html();
    // Notify with generated markup & cloned elements - useful for logging, etc
    try {
    options.deferred.notify('generated_markup', content, copy);
    } catch (err) {
    console.warn('Error notifying deferred', err);
    }
    // Destroy the copy
    copy.remove();
    if (options.iframe) {
    // Use an iframe for printing
    try {
    var $iframe = $(options.iframe + "");
    var iframeCount = $iframe.length;
    if (iframeCount === 0) {
    // Create a new iFrame if none is given
    $iframe = $('')
    .prependTo('body')
    .css({
    "position": "absolute",
    "top": -999,
    "left": -999
    });
    }
    var w, wdoc;
    w = $iframe.get(0);
    w = w.contentWindow || w.contentDocument || w;
    wdoc = w.document || w.contentDocument || w;
    wdoc.open();
    wdoc.write(content);
    wdoc.close();
    printFrame(w)
    .done(function () {
    // Success
    setTimeout(function () {
    // Wait for IE
    if (iframeCount === 0) {
    // Destroy the iframe if created here
    $iframe.remove();
    }
    }, 100);
    })
    .fail(function (err) {
    // Use the pop-up method if iframe fails for some reason
    console.error("Failed to print from iframe", err);
    printContentInNewWindow(content);
    })
    .always(function () {
    try {
    options.deferred.resolve();
    } catch (err) {
    console.warn('Error notifying deferred', err);
    }
    });
    } catch (e) {
    // Use the pop-up method if iframe fails for some reason
    console.error("Failed to print from iframe", e.stack, e.message);
    printContentInNewWindow(content)
    .always(function () {
    try {
    options.deferred.resolve();
    } catch (err) {
    console.warn('Error notifying deferred', err);
    }
    });
    }
    } else {
    // Use a new window for printing
    printContentInNewWindow(content)
    .always(function () {
    try {
    options.deferred.resolve();
    } catch (err) {
    console.warn('Error notifying deferred', err);
    }
    });
    }
    return this;
    };
    })(jQuery);

weixin_39178685
weixin_39178685 哥 这是什么
5 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!