Loads a local html file into the browser from a relative file path. If new_page==True, the page will switch to: "data:text/html," If new_page==False, will load HTML into the current page. Local images and other local src content WILL BE IGNORED.
(self, html_file, new_page=True)
| 3423 | self.load_html_string(html_string, new_page=new_page) |
| 3424 | |
| 3425 | def load_html_file(self, html_file, new_page=True): |
| 3426 | """Loads a local html file into the browser from a relative file path. |
| 3427 | If new_page==True, the page will switch to: "data:text/html," |
| 3428 | If new_page==False, will load HTML into the current page. |
| 3429 | Local images and other local src content WILL BE IGNORED.""" |
| 3430 | self.__check_scope() |
| 3431 | if self.__looks_like_a_page_url(html_file): |
| 3432 | self.open(html_file) |
| 3433 | return |
| 3434 | if len(html_file) < 6 or not html_file.endswith(".html"): |
| 3435 | raise Exception('Expecting a ".html" file!') |
| 3436 | abs_path = os.path.abspath(".") |
| 3437 | file_path = None |
| 3438 | if abs_path in html_file: |
| 3439 | file_path = html_file |
| 3440 | else: |
| 3441 | file_path = os.path.join(abs_path, html_file) |
| 3442 | html_string = None |
| 3443 | with open(file_path, "r") as f: |
| 3444 | html_string = f.read().strip() |
| 3445 | self.load_html_string(html_string, new_page) |
| 3446 | |
| 3447 | def open_html_file(self, html_file): |
| 3448 | """Opens a local html file into the browser from a relative file path. |