返回网络浏览器
我找不到任何这方面的文档。我的 C# Windows Phone 应用程序有一个 WebBrowser
控件,我希望有一个按钮让用户返回一页。我该怎么做? (我知道如何制作按钮或访问物理后退按钮,问题只是关于如何制作一个功能来让用户返回一页。
谢谢。
编辑:此外,如果没有什么可返回的,我会如果可能的话,想运行另一个函数。
编辑:尝试过: browser.InvokeScript("eval", "history.go(-1)");
,由于某种原因它不起作用。这编辑
:上面的内容与 e.Cancel = true;
一起使用,但是如果没有页面可返回...,如何恢复默认功能?
I can't find any doucmentation on this. I have a WebBrowser
control for my C# Windows Phone app, and I would like to have a button to take the user back one page. How can I do this? (I know how to make the button or access the physical back button, the question is just about how to make a function to take the user back one page.
Thanks.
EDIT: Also, if there's nothing to go back to, I'd like to run another function if possible.
EDIT: Tried this: browser.InvokeScript("eval", "history.go(-1)");
, it's not working for some reason. It just closes the app.
EDIT: Got the above working with e.Cancel = true;
but how do I restore the default function if there is no page to go back to...?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一些建议
该线程中建议的另一种方法是检查引用者。第一页通常没有引荐来源网址:
以调用
history.go()
脚本的方式调用这些脚本,看看是否有效。There are a couple of suggestions in this thread that may work, especially since you don't have to worry about multiple browsers. One way is to use the `history.length' property:
Another way suggested in that thread is to check the referrer. The first page doesn't usually have a referrer:
Invoke these scripts the same way you invoked the
history.go()
script and see if that works.