一、報錯信息:
“Blocked a frame with origin from accessing a cross-origin frame”
二、在stackoverflow上找到原因
Same-origin security policy You can't access an <iframe> with Javascript, it would be a huge security flaw if you could do it. For the same-origin policy browsers block scripts trying to access a frame with a different origin. (同源策略) Origin is considered different if at least one of the following parts of the address isn't maintained: <protocol>://<hostname>:<port>/path/to/page.html Protocol(協議), hostname(主機名) and port(端口) must be the same of your domain, if you want to access a frame.
iframe調用父頁面的函數:parent.functionNme();
ps:如果報以上錯誤,把iframe和父頁面代碼都放入工程項目中在本地跑起來即可解決同源問題。