[Solved][V2] set iframe onload event no effect

image

According to your code it will look for “testload” method in global window object

Try @load=“testload” instead

Thank you! it works.

By the way,the forums do not escape the html code, submitted before the html code directly rendered。So I converted the code into a picture。

You need to use special formatting to add code. You need to put ``` before code:

<iframe @load="testload"/>
<script>
  return {
    methods: {},
  }
</script>

2 Likes
<template>
<div class="page">

 <div class="navbar">

 <div class="navbar-inner sliding">

 <div class="left">

 <a href="#" class="link back">

 <i class="icon icon-back color-tmzl"></i>

 <span class="ios-only">Back</span>

 </a>

 </div>

 <div class="title">iframeTest</div>

 </div>

 </div>

 <div class="page-content">
<iframe @load="testload"/>
</div>
</div>
</template>
<script>

 return {

 methods: {

 load: function () {
 console.log("load iframe");
 }

 },

 on: {

 pageInit: function (e, page) {

console.log('pageInit');
 }

 })

 }

 }

 }

</script>

I found that the first output “load iframe”, after the output of “pageInit”,And the content of the iframe that I try to output is also empty ,This means that the load method executes if the contents of the iframe are not loaded。So how to monitor iframe content loading is complete

where do you load content to iframe?

Event load fires even with empty iframe (loaded empty page)

<iframe id="testiframe" @load="testload" src="http://forum.framework7.io"/>

testload: function () { console.log(document.getElementById('testiframe').contentWindow.document.documentElement.innerHTML); 

//console "<head></head><body></body>"
}

Upsss… security issue? Try to load page from the same domain/local path to test

Yeah, it is not allowed to access iframe content from other domain