browser

Generate single module with webpack, with optional-to-load parts of the same module

可紊 提交于 2021-01-29 06:45:32
问题 I've created a library of date/time functions. (Why? I need some special features other libraries like Moment.js don't have.) There are some big chunks of data for handling historical Daylight Saving Time info that most users won't need, so I'd like them to be something that can be loaded optionally. This works fine when code is being loaded directly from npm libraries, but I'm trying to make the same code work when loaded as scripts directly into a web browser from unpkg.com. I'm finding

Making Custom HTML Tags

耗尽温柔 提交于 2021-01-29 02:28:35
问题 I understand that you can make your own HTML tags, but how do I go about doing it? Can you make it once and then just use it over and over again in the same file without redefining it? Can you import it into other files? I also want to know if it is recommended to make custom HTML tags. Does it work in all browsers? I know this is a lot, so I will thank you in advance. 回答1: Why would you want to do that in the first place? Generally, people stick with existing tags and if they need to make

Detect browser close event

你说的曾经没有我的故事 提交于 2021-01-28 15:16:31
问题 I want to capture the browser window/tab close event. I have tried the following But not working: <script type="text/javascript"> window.onbeforeunload = function(){ myUnloadEvent(); } function myUnloadEvent() { alert ('Calling some alert messages here'); } </script> <body> Body of the page goes here. </body> Tried these links also but no more success. javascript to check when the browser window is close How to capture the browser window close event? javascript detect browser close tab/close

Is there any way to run Node.js in a <script> tag?

一曲冷凌霜 提交于 2021-01-28 14:27:19
问题 I would like to run Node.js in my webpage, the same way that you would with PHP or ASP.NET. The reason for this is I would like to use require()'d modules from NPM in my browser javascript, however vanilla JS doesn't seem to support this. Is there any way I can run Node.js in my tags? If not, would requiring examplenodefile.js in my browser javascript work? Edit: Is there any alternative to this, if it isn't possible? I know I can set script src but that doesn't really work as nicely as var

Making an XMLHttpRequest through a proxy?

白昼怎懂夜的黑 提交于 2021-01-28 07:53:21
问题 Is it possible to route HTTP requests through a proxy server programmatically from the browser with JavaScript? 回答1: Assuming you mean a standard HTTP proxy: No. The use of a proxy server is a browser configuration setting and cannot be changed (or even temporarily overridden) from JS. You could make an HTTP request to a regular HTTP endpoint on a server that determines the response it should make by making an HTTP request to a different server. 回答2: You can use some browser-extensions like

HTML : file-download: controle favicon and Tab-Title

痴心易碎 提交于 2021-01-28 06:02:33
问题 My file download works great. The file is delivered correctly. But I want to make it prettier. Is there a way to set a favicon and a window title, if I click on a html-download link to a file in a new tab? the file is generated and streamed by php. client part: <a target="_blank" tabindex="0" href="/path/to/file-download/interface" > server stream, while $file is some array holding file information: if (file_exists($file['path'])) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file(

Is it possible to detect if a user has opened a new tab?

孤街醉人 提交于 2021-01-28 05:16:25
问题 We are developing a quiz platform where we want to detect if the user opens a new tab during the quiz. The user is not allowed to open a new tab and we want to track this to notify the teacher managing the quiz. We are targeting the major browsers (IE, Chrome, Firefox, Safari). Is this possible? Thank you 回答1: You can use the onblur event of the window object and write something like this: function userCheated() { // The user cheated by leaving this window (e.g opening another window) // Do

JavaScript: How to determine performance of the runtime (aka browser)?

对着背影说爱祢 提交于 2021-01-28 03:31:08
问题 I have a JavaScript application, which works fine, but certainly needs some memory / CPU performance (it is based on top of Google maps). So basically it runs fine on a Desktop / Laptop PC, iPad works OK. But with all these different devices nowadays, smaller devices are definitely overloaded. So basically I want to determine the available runtime and decide whether I start my JavaScript application, or display a message instead. OK, I could check the browser, but this is a never ending story

JavaScript: How to determine performance of the runtime (aka browser)?

荒凉一梦 提交于 2021-01-28 02:20:23
问题 I have a JavaScript application, which works fine, but certainly needs some memory / CPU performance (it is based on top of Google maps). So basically it runs fine on a Desktop / Laptop PC, iPad works OK. But with all these different devices nowadays, smaller devices are definitely overloaded. So basically I want to determine the available runtime and decide whether I start my JavaScript application, or display a message instead. OK, I could check the browser, but this is a never ending story

Keep browser open while developing a test in Testcafe

南笙酒味 提交于 2021-01-27 20:00:39
问题 How to keep the browser window open after a test executes in Testcafe? There was a question on the forum here that brought me to a live Testcafe version, but it seems to be deprecated. I wish to keep the browser window open to see the elements while I'm developing the test. Update: This is my config file: { "name": "testcafe-demo", "version": "1.0.0", "description": "", "main": "index.js", "dependencies": { "testcafe": "^1.8.2" }, "devDependencies": {}, "scripts": { "test": "testcafe chrome