I am developing an intranet web application and the requirement is such that only one url should be opened at a time in chrome.
Currently the url is opened by a third party windows application on which we don't have any control!
Is there any way I can achieve that?
Summary is when the third party windows application opens the url (specified by me) all the other chrome tabs should close expect the current one.
Asuming all tabs are sharing the same domain, you can use JS localStorage with events on page load:
function storageChange(event) {
if(event.key == 'open') {
window.close();
//todo: except current window
}
}
window.addEventListener('storage', storageChange, false);
window.localStorage.setItem('open', true);
This will close all tabs with the same page loaded.
You should just detect the current one and keep it open
Finally I got my answer which was answered in another post in Chrome Extension to Loop to Close Non-Selected Tabs.
This solved my problem. All I had to do was close any window other than the current window. So at any point of time I will have only one chrome tab active.This solved my problem. Thanks for all your suggestions and comments. I am really sorry if I had said something wrong! Special thanks to #Harpyon ..
Related
I can't preview my Google Optimize experience. Google optimize throws below error:
This happens to me quite often too. The suggestion Google gives is wrong. Clearing cookies and restarting the browser does not fix it. Sometimes rebooting does, but that's a huge disruption.
What I found to work pretty reliably is to end the preview (dropdown), then click the EDIT button to go to the editor. Come back to the setup page, then try Debug again. Debugger should work again.
This is how it worked for me:
In Chrome go to Clear Browsing Data (chrome://settings/clearBrowserData).
Make sure you select checkboxes Cookies and Cached images and files.
Submit the form by hitting the button "Clear data".
Go to preview experience.
For me it started working when I gave the Google Optimize plugin access to all pages (not just the page running the experience).
I think I've found a fix for this. Go to the top right corner of chrome (the three dots) Settings > Privacy & Security > Cookies & other data > and add the url in the bottom section called "sites that can always use cookies"
Example
There can be multiple reasons.
Most obvious: enabled cookies like mentioned by others. should help
If it does not work even when cookies are enabled and you have restarted the browser then more chances are that the issue is in the Experience/Test that you are trying to preview. This can be due to:
A preview is already running in another tab. Turn off preview
2.You have set the experience to run on certain URL patterns and you are trying to preview on a page that does not qualify the criteria.
You have set some Audience rules which are not being met fully. For example: You have set the Audience Device type to mobile and you are trying to preview on a Desktop. Although Optimize will load the preview in a mobile mode but it will not be able to run the experience properly.
In my case the issue was due to wrong device type. I hope it helps.
It's also possible to get this "Unable to preview experience. Please make sure to enable cookies and restart the browser" error message if the content you're trying to modify doesn't exist when Optimize tries to modify it.
I had Optimize set to modify on page load, but the page I was working with was a form, where the text I wanted to modify didn't exist until I clicked through to the second step of the form (still on the same URL).
I was able to just run the study instead on another similar page that had all the text loaded at the start. I'd guess that setting Optimize to trigger from a custom event triggered upon loading the second step of the form instead of "on page load" would also have resolved the issue.
If you are using chrome then:
Click the context menu in the browser toolbar to the right of the
address bar.
Choose Settings.
Select/Search the "Security and Privacy" section.
Choose "Cookies and Other Site Data" Ensure that "Allow all cookies" is selected.
I am implementing a feature using "connectivity" from essentials that when the app goes "offline" no wifi etc.. it navigates to a specific page.
It works in most cases however if I set the phone on "Airplane Mode" when I am on a modal page it does not navigate to my page.
In Prism is there a way to detect if the current page "IsModal" and either goback or kill it so that I can navigate to my specific Page?
THanks
You'd have to write some crazy lookup logic to figure it out. Unfortunately the helper for that doesn't currently exist. However the latest Prism 7.2 preview has some enhancements that specifically attempt to eliminate the need to figure out whether you require Modal Navigation and automatically use the proper type of Navigation. I would encourage you to try the preview. If you come up with a scenario where GoBack isn't working correctly please open an issue.
we created a custom page which trigered by the component as Custom URL,
we have a close button on the page which calles a js function of window.close ,
it works for I.e and Chrome but not in FF.
we tried also to use local var that receive the window.open("","_self") and close it but didn't succeeded.
This is a browser issue and isn't specific to Tridion. Have a look at this thread which answers a similar question: How can I close a window with Javascript on Mozilla Firefox 3?
How i can close current web form in web based application?
I have tried with following code:
mybutton.Attributes.Add("onclick","window.close()")
But its not working
Help me. Thank you.
You can use window.close() to close a pop-up window only. If you really need to close the window, use a pop-up instead. However review why the closing is important? You may consider a redirection (either server.transfer or response.redirect).
Update:
Looking at the discussion at this stage, we need to see the relevance of why wee need to close the window as desired. What is the business value that we are achieving?
You can use the following script to close the current window in Chrome and IE (I checked in IE8).
mybutton.Attributes.Add("onclick", "window.open('', '_self');window.close();");
but it still won't work in Firefox. See more info on this: How can I close a window with Javascript on Mozilla Firefox 3?
But because it is a workaround (as Kangkan said window.close() should be used only to close popup window created by window.open() ), it is not a reliable solution and can be broken if a new browser version is out.
Bottom line: there is no reliable, universal solution for your problem, there is no proper way to close a non-popup window from javascript. If you can rely on the fact that your site will be used only in IE, Chrome, etc. you can use a workaround/hack (see above - but don't forget, it can easily be broken in next browser release), otherwise you should consider a different approach of the problem, instead of closing the window.
Can any one tell how to disable focus to a browser.
Hi i am currently working in .net application and i need to disable the tab focus to browser objects such as toolbars,address bar, since the user will not be using these components often
Thank you
Please don't do this, it breaks what the user expects a webpage to do. Messing with the fundamental behavior breaks several things:
My tab button and where I expect it to go
Screen readers for the disabled
Trust in your application
In some cases, you need to ask why? before asking how?, this is one of those. Anything that behaves differently from the other 99.9999% of the web is broken in the eyes of your user.
Well, I agree with Nick Craver. If you have to disable due to some crap requirements, then try opening a new window without toolbar, editable address bar etc and load the page inside the newly opened window.