I have tried below pieces of code to close current browser tab but none are working.
In fact they behave in yii2 way and try to navigate to same Controller/Action.
Click to Close
Click to Close
The View in which above code is written is a PHP page. any help?
Try:
Click to Close
UPDATED:
Note: there is browser-specific differences with the above. If you opened the window with Javascript (via window.open()) then you are allowed to close the window with javascript. Firefox disallows you from closing other windows. Other browsers may vary.
Related
I am attempting to view the HTML source code of the following link like so in chrome:
view-source:https://rankyourbrain.com/mental-math/mental-math-test-easy/submit
But it just redirects to
view-source:https://rankyourbrain.com/mental-math/mental-math-test-easy
What is happening? Is there a way to prevent this (or view source another way)?
Also, let me know if this is the incorrect forum to ask this question...
From the website you wish to view-source, hit F12 inside Chrome to view the debugger. On the Network tab, click the Preserve log checkbox.
Now you can view source without the redirects preventing the source-view page from displaying.
Alternatively, you could use a browser like Safari (on MacOS) to view source and the redirects won't affect it.
The below URL shows some XML in a <code> tag. It works fine in say Edge and Firefox but in Chrome, the markeup shows for a second then disappears just leaving the values as you can see below. Why is this happening in Chrome?
https://basketball.exposureevents.com/api/resources/venues
First, try hard refresh, it's simple thing that may solve the problem (if the source of it is in the specific site's CSS/JS code) (Windows: Ctrl+F5, Mac: Cmd+Shift+R)
Second, try update you'r Chrome to the last version (70.0.3538.67), go to on the top bar, there you can see if there is a new update (if there is, it will show up at the first line).
You can check you'r Chrome's version in this link: chrome://settings/help or go to on the top bar > Help > About Google Chrome.
If you'r Chrome is up to date, you may have some plugin/s that removing the xml tags.
Try accessing to this page via Incognito Mode (Windows: Ctrl+Shift+N, Mac: Cmd+Shift+N).
If it's working in the Incognito Mode, back to you'r main Chrome and then click on on the top bar > More tools > Extensions. Then, disable all of them and try to enable them one-by-one, on each one you'r enabled, go and check again if the problem is still there.
*Note that some plugins may be enabled also for Incognito Mode, so try the last step anyway.
Update: As much as I understand, the root issue is that your code was wrapped with html <pre> tag, that makes the browser to treat the XML as HTML tags, that are invisible when rendered in browser.
I have a popup window which has a cancel button. I want the window to close on the click of the button. The window.close() function performs the task in Chrome, but not on other browsers. Or even app. I want the popup to close on web and app both. Please help.
<button onclick="window.close()" class="cancel">CANCEL</button>
As discussed in the comments, the browser might prevent you from closing a window through window.close() if said window was not opened by Javascript in the first place (i.e. window.open()). (1)
You can confirm this by checking the browser console, which reports the following error:
Scripts may close only the windows that were opened by it.
The solution to such problem would be to ensure that said window is opened through window.open().
(1) https://developer.mozilla.org/en-US/docs/Web/API/Window/close
<a href="http://192.168.1.1"
onclick="Popup=window.open('http://192.168.1.1','Popup','toolbar=no,location=no,directories=
no,status=no,menubar=no,scrollbars=yes,resizable=no,width=800,height=300,left=300,top=23');
return false;" >
<button type="button">button</button></a>
If i'm browser this page in firefox, it pop up a new window in firefox when i click button.
if in chrome, then it pop up in chrome.
What if i want the pop up window always open in IE even when im browser this page in other browser?
Thanks!
Browsers cannot start other programs except with a plugin installed.
You can't do this. It breaks the sandbox model -- javascript in chrome, firefox, etc., executes in a security sandbox and there are lots of things it can't do. It can't save files to your hard disk (malicious code could overwrite your OS) -- it can't open arbitrary executables or start processes (malicious code could run a virus/malware). Javascript doesn't have the ability to do this.
As mentioned, browsers cannot start other programs without plugins or similar functionality.
I think your best bet is to detect IE on the other page. I don't believe there's a way to force IE. You could provide the link for them to easily copy and paste into IE, such as in a text box that is fully selected when they click in it.
I am using Google Chrome to test my Webapplication. With Control-U you can see the sourcecode of a page.
However it does not display the html/css that was added by ajax or that was created by jQuery. How can I make sure that I see all sourcecode?
You can view the created source using the developer tools.
On windows press Ctrl + Shift + J,
Click on the elements tab and there is is.
You can also do a bunch of other stuff too.
Try using the javascript inspector, similar to tools such as firebug in firefox. You can right click on an element and select "Inspect Element" to open it on that element. It should show you what was already there and what's been added through ajax.
You can serialize the document with XMLSerializer (Firefox, Chrome and Opera maybe IE (cannot test))
see this Fiddle
View Source doesn't work the same in Chrome as it does in some other browsers -- when chosen, it redownloads the page and displays the resulting HTML, rather than displaying the HTML that was used for the current page.