Search code examples
javascripthtmlvue.jsobjectfullscreen

how to prevent HTML object element with binded data attribute from refreshing after full screen on "samsung internet" browser


I have bound the data attribute of an HTML object element in a Vue component, and I have a full-screen button to show my object in full-screen mode.

there is no problem in chrome or other browsers, but when I try to show my object in full-screen mode on the Samsung internet browser, my object reconnects and I have to refresh the page.

I had watched the "gameLink" and it`s never changing on "toggleFullScreen", it only changes once on the created hook when it is initialized.

how can I prevent it from reconnecting?

here is the code:

        <b-nav-form>
            <b-button id="fullscreen-btn" @click="toggleFullScreen">
                <font-awesome-icon icon="expand" />
            </b-button>  
            <b-tooltip target="fullscreen-btn" placement="bottom" variant="warning">Full screen</b-tooltip>
        </b-nav-form>

. . . .

    <div class="game-screen-size">
        <div id="target" style="width:100%; height:100%;">
             <div v-if="fullscreen" style="position:fixed; top:15px; left:50%; z-index:1500">
                <b-button id="compress-btn" @click="toggleFullScreen">
                    <font-awesome-icon icon="compress" />
                </b-button>  
                <b-tooltip target="compress-btn" placement="bottom" variant="warning">Normall view</b-tooltip>
            </div>
            <object type="text/html" class="game-screen" :data="gameLink"></object>
        </div>
    </div>

. . . .

computed: {
    ...mapState("playGame", ["status", "gameLink", "userGameInfo", "activeTables", "emptyTables"]),
  },
methods: {
   ...mapActions("playGame", ["play", "userInfo", "tablesData"]),
    toggleFullScreen () {
        // toggle full screen using screenfull
        const element = document.getElementById('target');
        screenfull.toggle(element);
        this.fullscreen = !this.fullscreen;
      },
   }
created() {
    //gets the link and sets the gameLink on vuex store
    this.play();
}

....

video of the problem:

https://youtu.be/uIZuFwRqMKQ


Solution

  • I used iframe instead of object and problem solved!