Search code examples
phpjquerypopuppopupwindowpage-title

How to replace page title dynamically by popup box title?


My index page contains popup box. I want to replace index page title by popup box title if popup box clicked.

For example

<title><?php echo $title?></title>

I want to display as following:

<?php
    if(condition){      (->*such as #model2 is clicked*)
        $title="Model2 Section";
    }
    else{
        $title="Home"
    }
?>

I have used popup box as following:-> (link for popup box)

<article>
<a href="#modal2" class="dsnbutton ybank" id="pop_button">Model 2</a>
</article>

popup box

<div class="remodal" data-remodal-id="modal2" role="dialog" aria-labelledby="modal2Title" aria-describedby="modal2Desc">

How to change title ? Any Idea.


Solution

  • You can do this in JavaScript with document.title = "new title"