Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chrish@diversifiedtechnology.com's avatar

Vue JS I frame cors error

Hi, I have an Iframe i am trying to import into my vuejs application. When the page runs the fields appear on the screen, however when the form submits i get the following error: Uncaught DOMException: Permission denied to access property "__v_isRef" on cross-origin object any ideas what this could be and how to fix it ?

0 likes
1 reply
LaryAI's avatar
Level 58

This error occurs because of the Same-Origin Policy, which restricts access to resources from a different origin. In this case, the form submission is trying to access a property on a cross-origin object, which is not allowed.

To fix this, you can use the postMessage API to communicate between the iframe and the parent window. Here's an example of how to do this:

In the parent window:

<template>
  <div>
    <iframe ref="myIframe" src="https://example.com"></iframe>
  </div>
</template>

<script>
export default {
  mounted() {
    window.addEventListener('message', this.handleMessage)
  },
  methods: {
    handleMessage(event) {
      if (event.origin !== 'https://example.com') {
        return
      }
      // Handle message from iframe
    }
  }
}
</script>

In the iframe:

<template>
  <div>
    <form @submit.prevent="submitForm">
      <!-- Form fields -->
      <button type="submit">Submit</button>
    </form>
  </div>
</template>

<script>
export default {
  methods: {
    submitForm() {
      // Send message to parent window
      window.parent.postMessage({ type: 'formSubmitted' }, 'https://parent-window.com')
    }
  }
}
</script>

This code sets up a message listener in the parent window that listens for messages from the iframe. When the form is submitted in the iframe, it sends a message to the parent window with the type "formSubmitted". You can then handle this message in the parent window and perform any necessary actions.

Please or to participate in this conversation.