dse323222 2015-10-04 10:41
浏览 47
已采纳

通过php / html / javascript等控制浏览器的搜索栏文本

Is it possible to control search bar text of a browser via your website using HTML/PHP/CSS/Javascript or any other language. For example, if I have a website called wwww.mywebsite.com, containing 3 different pages e.g. home, pictures and videos and say for example, if the user goes on pictures page I want the website to detect the user is on the pictures page and then change the text in the search bar to www.mywebsite.com/youareviewingpictures or something.

Not sure if this will make sense but in Pesudo code it will look something like this;

IF current state of www.mywebsite.com page = pictures THEN
   Search Bar Text = "www.mywebsite.com/yourareviewingpictures"
ELSE
   Search Bar Text = "www.mywebsite.com"

If this is not possible, is it possible to write some code, say for example, on the pictures page which changes the search bar text when the user goes to the picture page.

I hope I have made myself clear, if not, please let me know and I will try explaining a bit better.

Thanks.

edit: What I want to know if, whether its possible to change the URL of a website via a code written inside the website that detects what page user is on and changes the URL accordingly.

For example, say I am on www.google.com and I open the the image page the url will change to something like www.google.com/images however, I want to detect via a code that user is on the image page and change the text of the url to say for example, www.google.com/imagepageopened

  • 写回答

3条回答 默认 最新

  • drz73366 2015-10-04 11:20
    关注

    You can do this very easily if you change the placeholder or value of input instead of the search bar text. Will serve the purpose.

    <script>document.getElementById("searchField").placeholder = window.location.href;</script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路