# Web Browser component -- how to initialize with a button?

**URL:** <https://forum.inductiveautomation.com/t/web-browser-component-how-to-initialize-with-a-button/91225>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [May 31, 2024, 7:52pm UTC](https://forum.inductiveautomation.com/t/web-browser-component-how-to-initialize-with-a-button/91225 "2024-05-31T19:52:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [May 31, 2024, 7:52pm UTC](https://forum.inductiveautomation.com/t/web-browser-component-how-to-initialize-with-a-button/91225/1 "2024-05-31T19:52:52Z")

</div>

Here are the properties of my Web Browser component. This is for a kiosk-style PC that is just used to access some .pdf's stored online. Menu bar is hidden, application starts full screen by default, that type of idea.

I want to add a button (or other component) to this screen that will force the web browser to initialize, a.k.a. go back to the starting URL. This is because I have removed the navigation buttons but still want a way for users to get back where they started in case they get lost. Possible? Note that I know exactly zero things about JxBrowser and Chromium switches, and it would be awesome to keep it that way.......

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/7/77373fa5cc16162dce7a53b3cde5b386e23d65d3.png)

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [May 31, 2024, 8:11pm UTC](https://forum.inductiveautomation.com/t/web-browser-component-how-to-initialize-with-a-button/91225/2 "2024-05-31T20:11:25Z")

</div>

I found something that works... I used `system.util.retarget()` and set the project name parameter to this project (self-referential). I put this in a client event script attached to a secret keystroke. So we can hit the keystroke and the project initializes. Pretty neat!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 31, 2024, 8:17pm UTC](https://forum.inductiveautomation.com/t/web-browser-component-how-to-initialize-with-a-button/91225/3 "2024-05-31T20:17:34Z")

</div>

Lighter weight than a full retarget: just close the window with the web browser and reopen it?

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [May 31, 2024, 8:54pm UTC](https://forum.inductiveautomation.com/t/web-browser-component-how-to-initialize-with-a-button/91225/4 "2024-05-31T20:54:03Z")

</div>

I like that idea. I just tested it out, and it is much faster. Problem is, when I reopen the window, the web browser has not initialized. It reloads back to the same screen I was looking at before closing the window. I can't find an obvious way around this so I will keep the retarget logic in place for now.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 31, 2024, 8:54pm UTC](https://forum.inductiveautomation.com/t/web-browser-component-how-to-initialize-with-a-button/91225/5 "2024-05-31T20:54:36Z")

</div>

Might work if you set the cache policy of the window to 'Never'?

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [May 31, 2024, 8:55pm UTC](https://forum.inductiveautomation.com/t/web-browser-component-how-to-initialize-with-a-button/91225/6 "2024-05-31T20:55:47Z")

</div>

That worked! Very nice... thank you so much!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 31, 2024, 8:57pm UTC](https://forum.inductiveautomation.com/t/web-browser-component-how-to-initialize-with-a-button/91225/7 "2024-05-31T20:57:34Z")

</div>

Even lighter weight, now that I've actually looked at the code... what if you changed the mode to 'html' and then back to 'url'? You might also need to reset the starting URL property in the meantime, though.

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [May 31, 2024, 9:06pm UTC](https://forum.inductiveautomation.com/t/web-browser-component-how-to-initialize-with-a-button/91225/8 "2024-05-31T21:06:50Z")

</div>

Even better. I have a docked view containing a button ("CLICK TO RESET") which contains the following event script:

```python
window = system.gui.getWindow('My Web Browser Window')
webView = window.rootContainer.getComponent('My Web Browser')
webView.mode = 1

def backToUrlMode():
	webView.mode = 0

system.util.invokeLater(backToUrlMode)

```

This works pretty much instantly. Really appreciate the help!
