Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X-Frame-Options & iframe & CORS #23

Open
xgqfrms opened this issue Aug 21, 2018 · 26 comments
Open

X-Frame-Options & iframe & CORS #23

xgqfrms opened this issue Aug 21, 2018 · 26 comments
Labels
iframe & frame & CORS iframe & frame & CORS iframe & frame iframe & frame X-Frame-Options & iframe & CORS X-Frame-Options & iframe & CORS X-Frame-Options X-Frame-Options

Comments

@xgqfrms
Copy link
Owner

xgqfrms commented Aug 21, 2018

X-Frame-Options

iframe & CORS

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options

bug

image

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 21, 2018

https://cn.bing.com/?intlF=&ensearch=1

如果服务器没配置,好像默认是禁用的(可以正常嵌入)。但是 页面的 js 执行不了.

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 21, 2018

image

Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.

sandbox

image

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 21, 2018

iframe & mdn

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe

const showDOM = (url = ``) => {
    let iframeBox = $qs(`[data-img-box="empty-iframe-page-box"]`);
    let no_data = `
        <p data-no-data="p">
            <span data-no-data="span">暂无数据</span>
        </p>
    `;
    try {
        if (url) {
            let iframe = document.createElement(`iframe`);
            iframe.src = url;
            // sandbox
            // srcdoc
            iframe.style.height = `100%`;
            iframe.style.width = `100%`;
            iframe.style.minHeight = `300px`;
            iframe.style.minWidth = `500px`;
            iframe.setAttribute(`sandbox`, `allow-scripts`);
            iframe.setAttribute(`sandbox`, `allow-scripts`);
            iframe.setAttribute(`data-iframe`, `empty-iframe-page`);
            iframe.setAttribute(`name`, `页面空模块`);
            if (iframeBox) {
                iframeBox.innerHTML = "";
                iframeBox.insertAdjacentElement(`beforeend`, iframe);
            }
        }
    } catch (err) {
        // no data
        iframeBox.innerHTML = "";
        iframeBox.insertAdjacentHTML(`beforeend`, no_data);
        throw new Error(`fetch image error`, err);
    }
};

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 21, 2018

Repository owner locked and limited conversation to collaborators Aug 21, 2018
@xgqfrms xgqfrms added X-Frame-Options X-Frame-Options X-Frame-Options & iframe & CORS X-Frame-Options & iframe & CORS labels Aug 21, 2018
@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 21, 2018

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 21, 2018

X-Frame-Options

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options#Syntax

X-Frame-Options: deny
X-Frame-Options: sameorigin
X-Frame-Options: allow-from https://example.com/

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 21, 2018

CSS & calc()

https://developer.mozilla.org/en-US/docs/Web/CSS/calc

.editorconfig

https://editorconfig.org/

# .editorconfig

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true


@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 21, 2018

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 21, 2018

clearfix

https://stackoverflow.com/questions/211383/what-methods-of-clearfix-can-i-use

https://css-tricks.com/snippets/css/clear-fix/

.clear-fixed::after {
   /* box-sizing: border-box; */
    content: "";
    display: block;
    visibility: hidden;
    overflow: hidden;
    clear: both;
    /* shit IE */
    zoom: 1;
    height: 0;
    font-size: 0;
}

css3 & vh & vw

https://snook.ca/archives/html_and_css/vm-vh-units

CSS Units

https://caniuse.com/#search=Units
https://www.w3schools.com/CSSref/css_units.asp
https://css-tricks.com/viewport-sized-typography/
https://css-tricks.com/fun-viewport-units/

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 21, 2018

code snippets

{
    "JavaScript ES6 React Template": {
        "prefix": "js6r",
        "body": [
            "\"use strict\";",
            "",
            "/**",
            " * ",
            " * @author xgqfrms",
            " * @license MIT",
            " * @copyright xgqfrms",
            " * ",
            " * @description $2",
            " * @augments $3",
            " * @example $4",
            " * ",
            " */",
            "",
            "const $2Generator = ($5datas = [], debug = false) => {",
            "    let result = ``;",
            "    // do something...",
            "    return $7result;",
            "};",
            "",
            "",
            "",
            "export default $2;",
            "",
            "export {",
            "    $2,",
            "};",
            "",
        ],
        "description": "JavaScript ES6 React Template & code snippets!"
    }
}
{
    "CSS3 Template": {
        "prefix": "c3t",
        "body": [
            "@charset \"UTf-8\";",
            "",
            "/**",
            " * ",
            " * @author xgqfrms",
            " * @license MIT",
            " * @copyright xgqfrms",
            " * ",
            " * @description $1.css",
            " * ",
            " */",
            "",
            ":root {",
            "   --cololr: #000;",
            "   --default-cololr: #fff;",
            "   --new-cololr: #0f0;",
            "}",
        ],
        "description": "CSS3 Template & code snippets!"
    }
}

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 22, 2018

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 22, 2018

水印

文档添加自定义的个性图片水印

http://www.icanzc.com/word/6234.html

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 22, 2018

钉钉 & 姓名字水印

http://blog.sina.com.cn/s/blog_14d40ba9a0102vv48.html

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 22, 2018

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 22, 2018

css bug

<!DOCTYPE html>
<html>
<head>
<style>
p{
    position: relative;
    text-indent: 36px;
}
span{
    position: absolute;
    display: inline-block;
    width: 16px;
    height: 16px;
    background: url("paper.gif") no-repeat;
    color: #0f0;
    background-color: #000;
    top: 50%;
    transform: translateY(-50%);
    left: 20px
}
</style>
</head>
<body>

<h1>Hello World!</h1>

<p> <span>X</span>This page has an image as the background!</p>

</body>
</html>

image

text-indent: 0px; & overflow: hidden;

https://www.w3schools.com/css/tryit.asp?filename=trycss_background-image

p{
    position: relative;
    text-indent: 36px;
}
span{
    position: absolute;
    display: inline-block;
    width: 16px;
    height: 16px;
    background: url("paper.gif") no-repeat;
    color: #0f0;
    background-color: #000;
    top: 50%;
    transform: translateY(-50%);
    left: 20px;
    text-indent: 0px;
    overflow: hidden;
}

@import & img path bug

@charset "UTf-8";

/* index.css */

@import url("./commons/reset.css");
@import url("./layout/aside.css");
@import url("./utils/accordion.css");
.accordion-item-title-icon {
    position: absolute;
    display: inline-block;
    width: 16px;
    height: 16px;
    color: #fff;
    background-color: #333333;
    /* @import & img path bug */
    background: url("../imgs/menus.png") no-repeat;
    background-position: 0 0;
    overflow: hidden;
    top: 50%;
    transform: translateY(-50%);
    left: 20px;
    text-indent: 0;
}

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 22, 2018

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 22, 2018

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 22, 2018

minify html

OK

    new HtmlWebpackPlugin({
        template: "./src/html/index.html",
        filename: "./index.html",
        chunks: ["index"],
        // chunks: ["app", "main"],// load modules order ??? fifo
        hash: true,
        // minify: true,
        minify: {
            collapseWhitespace: true,
            collapseInlineTagWhitespace: true,
        },
    }),

image

webpack minify html template bug code demo ?

https://stackoverflow.com/questions/36031931/how-to-minify-html-templates-using-angular2-and-webpack

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 22, 2018

// minify html
    new HtmlWebpackPlugin({
        template: "src/index.html",
        chunksSortMode: "none",
        minify: {
            collapseWhitespace: true,
            collapseInlineTagWhitespace: true,
            removeTagWhitespace: true,
            removeRedundantAttributes: true,
            removeEmptyAttributes: true,
            removeScriptTypeAttributes: true,
            removeStyleLinkTypeAttributes: true
        }
    }),

https://github.com/gdi2290/angular-starter

@xgqfrms
Copy link
Owner Author

xgqfrms commented Aug 22, 2018

OK

it's ok now

  1. jsut remove inject: false,

  2. manaully setting multi pages

    new HtmlWebpackPlugin({
        // inject: false,
        hash: true,
        chunks: ["app"],
        template: "./src/html/app.html",
        filename: "./pages/app.html"
        // filename: "./pages/[name].html"
    }),
    new HtmlWebpackPlugin({
        // inject: false,
        hash: true,
        chunks: ["main"],
        template: "./src/html/main.html",
        filename: "./pages/main.html"
    }),
    new HtmlWebpackPlugin({
        template: "./src/html/index.html",
        filename: "./index.html",
        chunks: ["index"],
        // chunks: ["app", "main"],// load modules order ??? fifo
        hash: true,
        // minify: true,
        minify: {
            collapseWhitespace: true,
            collapseInlineTagWhitespace: true,
        },
    }),

image

@xgqfrms xgqfrms added iframe & frame & CORS iframe & frame & CORS iframe & frame iframe & frame labels Feb 19, 2019
@xgqfrms xgqfrms pinned this issue Feb 19, 2019
@xgqfrms
Copy link
Owner Author

xgqfrms commented Feb 19, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iframe & frame & CORS iframe & frame & CORS iframe & frame iframe & frame X-Frame-Options & iframe & CORS X-Frame-Options & iframe & CORS X-Frame-Options X-Frame-Options
Projects
None yet
Development

No branches or pull requests

1 participant