[SOLVED] Window.open does not work on ios safari

we are creating a game and need to open some windows on button clicks, this does not seem to work on ios safari due to pop-up blocking. we already looked at other projects and are using the same code as the flappy bird tutorial project. It seems to work there, but not in ours. We also looked at some more general javascript solutions, but these also seem fruitless. Any help is appreciated, thanks!

Which buttons are meant to open new windows?

the red button at the top is easiest to test, but there are a few. mainly the share buttons on the game over screen.

alright, the solution is found! apparently it does not work when called after a button press, but it does work when called through an event. The buttons in our example are sprites that fire an event when clicked on, while our project worked with buttons. thanks for taking a look Yaustar.

Nice one in finding the solution and thank you for posting it here.

Yes, as a protection measure, browsers tend to only have operations like this only happen on the event callback.

:thinking:

  • Do Not Sell My Personal Info

Professional Website Builder

  •  ⋅ 

Don’t Use The Target=”_Blank” Link Attribute In These Cases

Get a clear overview of _blank link attribute and learn how to properly execute it to mitigate site security and performance-related risks.

Learn when (not) to use target="_blank" link attribute.

Using the _blank link attribute will cause the link to open in a new browser window or tab.

But it is not as straightforward as it seems.

It turns out that not only is the _blank link attribute a security risk, but there are also multiple situations when using something other than _blank is recommended.

In this article, you’ll learn when using the _blank attribute is not a good idea.

What Is The _Blank Link Attribute?

The _blank link attribute tells the browser to open a link within a brand new tab.

You can have multiple links that use the _blank link attribute, and every different link with that _blank attribute, when clicked, will spawn a brand new browser tab.

What’s more, if a user clicks the same link over and over, the browser will keep spawning more and more tabs.

Is The _Blank Attribute Unethical?

There are some who are of the opinion that it’s best to give the user the choice to open a new browser tab.

Some people assert that it’s unethical to “trap” a user on your site by opening links on a new browser window and keeping your own web page open, as well.

The problem with that point of view is that quite likely most people don’t know that they have a choice to open a new browser window.

Every site audience is technically adept at different levels .

But it’s probably safe to say that many people still don’t know that they can right-click (or long-click on a mobile device) and choose to open a new browser tab.

So, giving users a “choice” really isn’t a choice.

They’re just going wherever you send them.

One person’s “ethical” choice to open a link in the same web browser can confuse the site visitor if they try to get back to the original web page by closing the browser tab they are currently in.

The question of ethics has largely been set aside nowadays.

The choice of whether to use the _blank link attribute or not is a personal and a business choice.

There’s A Security Reason For Not Using _Blank

The target=”_blank” link attribute is risky and opens a website to security and performance issues.

Google’s Web.dev page on the risks of using the _blank link attribute is summarized as such:

“The other page may run on the same process as your page. If the other page is running a lot of JavaScript, your page’s performance may suffer. The other page can access your window object with the window.opener property. This may allow the other page to redirect your page to a malicious URL.”

The solution?

Use the rel=”noopener” or rel=”noreferrer” link attributes for every link.

  • The rel=”noopener” link attribute prevents the linked site from receiving access to the original web page that is linking out. This prevents the linked site from taking control or otherwise influencing the linking site.
  • The rel=”noreferrer” link attribute hides the referrer information from the site that is being linked to. When a site visitor clicks a rel=”noreferrer” link, the site being linked to won’t know what site referred the visitor.

The rel=”noreferrer” link attribute also functions the same as the “noopener” link attribute in that it prevents the linked site from taking control of the linking site.

So, if you want to send websites referrer information while protecting yourself from the _blank link attribute security issues, use the “noopener” link attribute.

If you’d rather stay private and not pass along referrer information while also protecting yourself from security issues associated with using the _blank link attribute, then use the rel=”noreferrer” link attribute.

Data Security Considerations For Sensitive Pages

There are specific situations related to security where a publisher may not want a user spawning multiple web pages. One such case is a website that deals with sensitive customer information.

If a health or finance-related website uses _blank for links to private information, it may cause the site visitor to spawn multiple web pages with sensitive information.

They may unknowingly leave these windows open unintentionally.

For example, they may close the main window and another window and be unaware there might be a third window with highly confidential information still open in a background tab of the browser.

In that case a site publisher may choose to use a different link attribute like “blank” (with the underscore _).

The “blank” link attribute will open a link on a brand new browser tab.

However, unlike the _blank link attribute, all the other links on the original web page will also open the linked page on the same tab as the first clicked link.

So, if you have five links on a page that use the “blank” link attribute, and a user clicks the first link, any of the other four links when clicked will open the web pages on the same browser tab as the first clicked link.

Alternate To _Blank Attribute

You don’t have to use _blank, by the way. You can use a different word.

The difference between using _blank and any other word is that using another word will restrict every link on that page to opening within the same new browser tab.

For example, if you code a link like this:

The above link will open in a brand new browser tab.

Now, if you have two links with the same link attribute:

If a site visitor clicks on the first link, it will spawn a new browser tab.

If the site visitor clicks the second link, it will open the link in the same browser tab as the first link that was clicked, essentially reusing that same browser tab.

You May Not Want To Use _Blank For Inline Frames

There may be times when a publisher may need to use something other than the _blank attribute.

One such case is for inline frames.

An inline frame is an HTML element that can contain another web document within it.

For example, some advertisements are contained within an iframe so that they end up being a web page within a web page.

An inline frame is coded with the iframe element (also called an iframe tag).

Because an iframe is essentially a web page that’s embedded within another web page, the HTML specifications have link attributes that are specific to the iframes that will cause links embedded within an iframe to behave a certain way.

It’s still possible to use the _blank within an iframe to spawn a web page in a new browser tab. But, it’s not recommended if you want a specific behavior for an iframe.

There are three iframe-specific link attributes to choose from:

  • _parent: It will open a link outside of an iframe (as well as within the same web page).
  • _self: It will open the link within the same iframe (or the same web page) but only if the link is on the same domain. It won’t work if the link is to another domain.
  • _top:  It will open outside of an iframe (as well as within the same web page).

_Blank Link Attributes

When it comes to the _blank link attribute, it’s probably okay to generalize and simply use it as long as you have a noreferrer or noopener link attribute attached to it.

With that said, it’s good to know there are alternatives.

Ultimately, the use of the _blank link attribute is as easy and as complicated as you want to make it, and it depends on your specific needs.

More resources:

  • How to Use the Link Title Attribute Correctly
  • 9 HTML Tags (& 11 Attributes) You Must Know for SEO
  • Advanced Technical SEO: A Complete Guide

Featured Image: Viktoria Kurpas/Shutterstock

I have 25 years hands-on experience in SEO and have kept on  top of the evolution of search every step ...

Subscribe To Our Newsletter.

Conquer your day with daily search marketing news.

Window.open with ios for an async function not working

In my app so far all the window.open calls work fine on iOS but this one is using an async function.

Is there a solution for this? I have spent several hours trying various things from stackoverflow.

I have seen that installing the inAppBrowser may help which I have not tried yet.

I also saw that putting the window.open in the click event may allow it but this would require the user to make another click which is not ideal.

I am not a big fan of async and await because they obscure what is actually happening, and this may be easier to track down if you get rid of them.

That being said, I have a hunch.

Hopefully you control the code to stripeService . If you don’t, I’m sure you can modify this advice accordingly, though.

Replace your createStripePortalSession with a call to createSafeStripePortalSession instead, and make it look like this:

See if it fixes your problem. If so, the reason it works is that the Promise coming from Stripe’s API isn’t zone-aware. I ran into this problem with Promise s that come from WebCrypto, and wrapping them with another Promise.resolve is the cleanest way I came up with to zonify them. You could do something similar with NgZone.run , but I hate that because it needlessly exposes implementation details that should be subject to change.

That didn’t work.

Here is what I tried.

It is actually calling my own firebase cloud function which is then calling Stripe from there so I have control of the cloud function too.

Amongst the “many things tried from stackoverflow”, did you try:

Yeah I did try that. The window.open works (although I need to give it a url) but it seems to lose the reference so the wref.location does not work. I think this probably only works for web.

OK, I think we’re at the point where this topic could be renamed “help me make Stripe play nicely with Safari’s popup blocker”.

There seem to be many different APIs and assorted plugins out there for interacting with Stripe. Perhaps an overview of which you are using under the hood here might help suggest further lines of inquiry.

Safari apparently really doesn’t want windows spawned from code that is not a direct response to a user input, which I guess is sort of understandable but probably sort of irritating in this precise situation. I’m sure you’re not the only one who’s hit this, but I think it’s important to focus on Stripe-related options, because generic attempts at solutions seem to be hitting a brick wall.

Yeah ios can be a real pain.

I’m going to search for a few more things to try. The next thing I will try is the in app browser as I saw mention that it resolved the problem, even if you open the window in the system browser.

If none of that works I will resort to having two buttons or creating the portal session if the user goes to that page. Not great solutions but either should work.

I have no idea why the inappbrowser solution would work though.

I fixed it easily with the below but it is not a great solution as the user has click twice. I may just leave it like this for a while rather than expending any more time on it.

Hello everyone. Does someone have any news regarding this issue?

I use Capacitor, and my users log in using OpenID Connect (with angular-auth-oidc-client), because of company policies, we can’t use the inAppBrowser, and have to rely on the system browser.

This code works on Android, but not on iOS:

So I managed to make it work using the solution provided by @wekas with a popup, but it’s definitely annoying for the users to clic on “Login”, and then have a popup to confirm that he, indeed, wants to login…

Window.open function not work on safari ios and safari For more information you can have a look on the documentation Window.open() - Web APIs | MDN

This is false, and MDN docs says that window.open is compatible since Safari iOS version 1.

The issue here is that it doesn’t work in an async callback in Ionic.

If there is another way to open the native browser, I would be very interested in that.

window.open work on safari browser version 1 but not with latest version of safari browser.

There are some plugin you can use for native browser it may help you.

For capacitor

For cordova

For web window.location.href

Thanks for your reply, but I feel like we’re going in circle here.

Opening safari works well on iOS 16.2 with window.open, as long as it’s not in an async function . In the code I provided, opening safari works, it just does so on user action.

The plugins you provided uses inApp browser, and I can’t use that.

I really feel like it’s an issue with Ionic itself.

  • Skip to main content
  • Skip to search
  • Skip to select language
  • Sign up for free

Window: open() method

The open() method of the Window interface loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe ) under a specified name.

A string indicating the URL or path of the resource to be loaded. If an empty string ( "" ) is specified or this parameter is omitted, a blank page is opened into the targeted browsing context.

A string, without whitespace, specifying the name of the browsing context the resource is being loaded into. If the name doesn't identify an existing context, a new context is created and given the specified name. The special target keywords , _self , _blank , _parent , _top , and _unfencedTop can also be used. _unfencedTop is only relevant to fenced frames .

This name can be used as the target attribute of <a> or <form> elements.

A string containing a comma-separated list of window features in the form name=value — or for boolean features, just name . These features include options such as the window's default size and position, whether or not to open a minimal popup window, and so forth. The following options are supported:

If this feature is enabled, it requests that a minimal popup window be used. The UI features included in the popup window will be automatically decided by the browser, generally including an address bar only.

If popup is not enabled, and there are no window features declared, the new browsing context will be a tab.

Note: Specifying any features in the windowFeatures parameter, other than noopener or noreferrer , also has the effect of requesting a popup.

To enable the feature, specify popup either with no value at all, or else set it to yes , 1 , or true .

Example: popup=yes , popup=1 , popup=true , and popup all have identical results.

Specifies the width of the content area, including scrollbars. The minimum required value is 100.

Specifies the height of the content area, including scrollbars. The minimum required value is 100.

Specifies the distance in pixels from the left side of the work area as defined by the user's operating system where the new window will be generated.

Specifies the distance in pixels from the top side of the work area as defined by the user's operating system where the new window will be generated.

If this feature is set, the new window will not have access to the originating window via Window.opener and returns null .

When noopener is used, non-empty target names, other than _top , _self , and _parent , are treated like _blank in terms of deciding whether to open a new browsing context.

If this feature is set, the browser will omit the Referer header, as well as set noopener to true. See rel="noreferrer" for more information.

Note: Requested position ( top , left ), and requested dimension ( width , height ) values in windowFeatures will be corrected if any of such requested value does not allow the entire browser popup to be rendered within the work area for applications of the user's operating system. In other words, no part of the new popup can be initially positioned offscreen.

Return value

If the browser successfully opens the new browsing context, a WindowProxy object is returned. The returned reference can be used to access properties and methods of the new context as long as it complies with the same-origin policy security requirements.

null is returned if the browser fails to open the new browsing context, for example because it was blocked by a browser popup blocker.

Description

The Window interface's open() method takes a URL as a parameter, and loads the resource it identifies into a new or existing tab or window. The target parameter determines which window or tab to load the resource into, and the windowFeatures parameter can be used to control to open a new popup with minimal UI features and control its size and position.

Remote URLs won't load immediately. When window.open() returns, the window always contains about:blank . The actual fetching of the URL is deferred and starts after the current script block finishes executing. The window creation and the loading of the referenced resource are done asynchronously.

Modern browsers have strict popup blocker policies. Popup windows must be opened in direct response to user input, and a separate user gesture event is required for each Window.open() call. This prevents sites from spamming users with lots of windows. However, this poses an issue for multi-window applications. To work around this limitation, you can design your applications to:

  • Open no more than one new window at once.
  • Reuse existing windows to display different pages.
  • Advise users on how to update their browser settings to allow multiple windows.

Opening a new tab

Opening a popup.

Alternatively, the following example demonstrates how to open a popup, using the popup feature.

It is possible to control the size and position of the new popup:

Progressive enhancement

In some cases, JavaScript is disabled or unavailable and window.open() will not work. Instead of solely relying on the presence of this feature, we can provide an alternative solution so that the site or application still functions.

Provide alternative ways when JavaScript is disabled

If JavaScript support is disabled or non-existent, then the user agent will create a secondary window accordingly or will render the referenced resource according to its handling of the target attribute. The goal and the idea are to provide (and not impose ) to the user a way to open the referenced resource.

The above code solves a few usability problems related to links opening popups. The purpose of the event.preventDefault() in the code is to cancel the default action of the link: if the event listener for click is executed, then there is no need to execute the default action of the link. But if JavaScript support is disabled or non-existent on the user's browser, then the event listener for click is ignored, and the browser loads the referenced resource in the target frame or window that has the name "WikipediaWindowName" . If no frame nor window has the name "WikipediaWindowName" , then the browser will create a new window and name it "WikipediaWindowName" .

Note: For more details about the target attribute, see <a> or <form> .

Reuse existing windows and avoid target="_blank"

Using "_blank" as the target attribute value will create several new and unnamed windows on the user's desktop that cannot be recycled or reused. Try to provide a meaningful name to your target attribute and reuse such target attribute on your page so that a click on another link may load the referenced resource in an already created and rendered window (therefore speeding up the process for the user) and therefore justifying the reason (and user system resources, time spent) for creating a secondary window in the first place. Using a single target attribute value and reusing it in links is much more user resources friendly as it only creates one single secondary window, which is recycled.

Here is an example where a secondary window can be opened and reused for other links:

  • Same-origin policy

If the newly opened browsing context does not share the same origin , the opening script will not be able to interact (reading or writing) with the browsing context's content.

For more information, refer to the Same-origin policy article.

Accessibility concerns

Avoid resorting to window.open().

It is preferable to avoid resorting to window.open() , for several reasons:

  • Modern browsers offer a popup-blocking feature.
  • Modern browsers offer tab-browsing, and tab-capable browser users prefer opening new tabs to opening new windows in most situations.
  • Users may use browser built-in features or extensions to choose whether to open a link in a new window, in the same window, in a new tab, the same tab, or in the background. Forcing the opening to happen in a specific way, using window.open() , will confuse them and disregard their habits.
  • Popups don't have a menu toolbar, whereas new tabs use the user interface of the browser window; therefore, many users prefer tab-browsing because the interface remains stable.

Never use window.open() inline in HTML

Avoid <a href="#" onclick="window.open(…);"> or <a href="javascript:window\.open(…)" …> .

These bogus href values cause unexpected behavior when copying/dragging links, opening links in a new tab/window, bookmarking, or when JavaScript is loading, errors, or is disabled. They also convey incorrect semantics to assistive technologies, like screen readers.

If necessary, use a <button> element instead. In general, you should only use a link for navigation to a real URL .

Always identify links leading to a secondary window

Identify links that will open new windows in a way that helps navigation for users.

The purpose is to warn users of context changes to minimize confusion on the user's part: changing the current window or popping up new windows can be very disorienting to users (in the case of a popup, no toolbar provides a "Previous" button to get back to the previous window).

When extreme changes in context are explicitly identified before they occur, then the users can determine if they wish to proceed or so they can be prepared for the change: not only they will not be confused or feel disoriented, but more experienced users can better decide how to open such links (in a new window or not, in the same window, in a new tab or not, in "background" or not).

  • WebAIM: Links and Hypertext - Hypertext Links
  • MDN / Understanding WCAG, Guideline 3.2
  • G200: Opening new windows and tabs from a link only when necessary
  • G201: Giving users advanced warning when opening a new window

Specifications

Browser compatibility.

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

  • <form>
  • window.close()
  • window.closed
  • window.focus()
  • window.opener
  • rel="opener" and rel="noopener"

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page.open doesn't work on iOS #14865

@gpsfl

gpsfl commented Oct 17, 2022

@caalador

caalador commented Oct 25, 2022

Sorry, something went wrong.

gpsfl commented Oct 25, 2022

Caalador commented oct 26, 2022.

@franrolando

franrolando commented Mar 17, 2023

No branches or pull requests

@caalador

Fly_PetitPrince

BUG Safari 17.1: Open new window instead of new tab

In Safari, there's an option that lets you open a page in a new TAB rather than in a new WINDOW.

This option brings up a warning message if you choose "Always" :

ios safari window open _blank not working

(sorry, my Safari is in french)

On Safari 17.0 and earlier version: no problem, it worked fine.

On Safari 17.1, links that require the window to be a particular size are no longer opened in a NEW TAB but in a NEW WINDOW, even if the "ALWAYS" option is activated.

This can be tested, for example, on this web page, which contains two "Open page in new window" links to test:

https://www.rapidtables.com/web/html/link/html-link-new-window.html

First link: open correctly in a new TAB (if ALWAYS is activated).

Second link: open in a NEW WINDOW (if ALWAYS is activated) --> should not be the case.

ios safari window open _blank not working

Do you know whether Safari 17.2 or 17.3 or higher will correct this problem?

Thank you very much,

PS: using MAC Mini M2. I kept the MacBook Air with Safari 17.0 which allowed me to see that it was working on 17.0 and not working anymore on 17.1 > I then updated MacBook Air to 17.1, the problem appeared.

Mac mini (M2, 2023)

Posted on Oct 31, 2023 3:53 AM

Similar questions

  • Mojave Safari Bug: Open In New Tab Opens Both New Tab AND in Current Recently Safari has developed a bug that will force me to switch to Chrome for good. Problem: I right click on a link, select "Open in New Tab" and a new tab opens, BUT the content also load in current tabs, effectively defeating the "Open in New Tab" functionality. Ineffective "Solution": A reply to this post https://discussions.apple.com/thread/8651910 someone suggested "Open Safari > Preferences > General and choose what you want to open under "New tabs open with:" from the drop down menu." This did not solve the problem. I use "Open in New Tab" as a regular part of my workflow. This bug in basic functionality is like trying to drive a car with 4 flat tires. It doesn't work. I am using: OS 10.14.4 (Mojave), Safari Version 12.1 (14607.1.40.1.4) Any help appreciated. Thank you. Amanda 375 2
  • Safari Problems I don't know a good title for this post, my issue is, Safari 15.3 has been giving issues, like when I go to a link, it will go there, and immediately go back and act as if I never clicked the link. It happens other times too, like I will close a tab, and it will re-open the tab. This started happening I believe around a large MacOS update, and has gotten steadily worse. It doesn't happen on other browsers, just Safari-but I really like Safari and want to continue using it. Has anyone else experienced this? My system is a 14" MacBook Pro, but this issue happened on my old 12" MacBook as well. 375 3
  • Command-click not opening new tab in Safari In Safari, when I do 'Command-Click' on a link inside a web page, it should open up the linked page in a new tab. And it does, except for one particular website (ctvnews.ca) - for this site, the linked page replaces the original page, just as if I had done a simple Click. Why would just this one website do this while all the others behave properly? And what can I do about it? 288 6

Loading page content

Page content loaded

Nov 8, 2023 1:48 AM in response to Fly_PetitPrince

Just installed Sonoma 14.1.1 and problem is still there (opening in NEW WINDOW instead of NEW TAB).

But Safari is still in 17.1.

Could someone make the test, to know if I am alone or not ?

Many thanks,

smittyrocks

Nov 8, 2023 12:53 PM in response to Fly_PetitPrince

I see the same thing happening in our PSA app, AutoTask. With Safari v17, we could set the Safari setting to open all links in tabs, no windows. But now in v17.1 there are certain javascript links that now only open in a window even if the Safari setting is set properly. Even AutoTask has an option to force all tabs and v17.1 but it still doesn't work. I too am running a 2023 M2 Mac mini.

Michael Ferry

Nov 9, 2023 6:51 AM in response to Fly_PetitPrince

It looks like the recommended approach is with the "Feedback Assistant" app, included with macOS (a Spotlight Search should find it for you, it's in a System folder).

Feedback Assistant is also on the web: https://feedbackassistant.apple.com/

There's also a more generic feedback form at https://www.apple.com/feedback/safari.html

LKBLKB

Nov 5, 2023 4:27 PM in response to Fly_PetitPrince

I have Sonoma 17.2 and cannot get Safari to open new web pages at all. No problems on Chrome and I'm about to totally abandon Safair. Someone please help with this!

Nov 2, 2023 1:14 AM in response to Fly_PetitPrince

UP - Any idea pleaseeeeee ?

It's really annoying, I would like at least that someone does the same test than me, to let me know if I am alone with that problem or if it is reproductible...

Nov 6, 2023 11:40 PM in response to LKBLKB

@LKBLKB lucky you are, you have the inverse behavior than I have ? You can't open webpage in new window but in new tab only ? On my side, it's the opposite.

Have you tried with the URL I mention, to make the test ?

https://www.rapidtables.com/web/html/link/html-link-new-window.html --> click on open new page, what's happening on your side ?

PS: here I have Sonoma 14.1 and Safari 17.1

Nov 8, 2023 11:40 PM in response to smittyrocks

Many thanks @smittyrocks for confirming the issue, and also with a third party app which should force the window to open in tab.

So now, cross finger that it is read enough by MAC OS Dev and we get a debug version...

Any idea how to report a bug ?

kecinzer-cz

Feb 23, 2024 12:15 AM in response to Fly_PetitPrince

Same issue here. I'm currently on macOS 14.3.1 (23D60) and Safari 17.3.1 (19617.2.4.11.12) still not fixed. This driving me crazy. I already reported issue by Feedback Assistant (FB13284384) but without any reply.

imazeno

Mar 2, 2024 6:50 AM in response to Fly_PetitPrince

I find whether Safari has a regular window open in any of the visible Spaces affects the bevaviour for setting to open links in windows / tabs. If there is a Safari window on screen already, the setting works as it says for me.

In the opposite case, when I have a full-screen Safari in another Space, the link will always open in that window as a new tab, regardless of the setting.

Personally I want the new link to open in a separate window, but it sounds like using a full screen Safari windows might be to your liking.

Oct 31, 2023 11:41 PM in response to Fly_PetitPrince

Any idea ? I am working on a MAC Mini M2 2023

Mac keyboard shortcuts

By pressing certain key combinations, you can do things that normally need a mouse, trackpad, or other input device.

Using keyboard shortcuts

Common shorcuts like cut, copy, paste

Sleep, log out, and shut down shortcuts

Finder and system shortcuts, document shortcuts, accessibility shortcuts, other shortcuts.

To use a keyboard shortcut, press and hold one or more modifier keys and then press the last key of the shortcut. For example, to use Command-C (copy), press and hold the Command key, then the C key, then release both keys. Mac menus and keyboards often use symbols for certain keys , including modifier keys:

Command (or Cmd) ⌘

Option (or Alt) ⌥

Control (or Ctrl) ⌃

Caps Lock ⇪

On keyboards made for Windows PCs, use the Alt key instead of Option, and the Ctrl key or Windows logo key instead of Command.

Cut, copy, paste, and other common shortcuts

Command-X : Cut the selected item and copy it to the Clipboard.

Command-C : Copy the selected item to the Clipboard. This also works for files in the Finder.

Command-V : Paste the contents of the Clipboard into the current document or app. This also works for files in the Finder.

Command-Z : Undo the previous command. You can then press Shift-Command-Z to Redo, reversing the undo command. In some apps, you can undo and redo multiple commands.

Command-A : Select All items.

Command-F : Find items in a document or open a Find window.

Command-G : Find Again: Find the next occurrence of the item previously found. To find the previous occurrence, press Shift-Command-G.

Command-H : Hide the windows of the front app. To view the front app but hide all other apps, press Option-Command-H.

Command-M : Minimize the front window to the Dock. To minimize all windows of the front app, press Option-Command-M.

Command-O: Open the selected item, or open a dialog to select a file to open.

Command-P : Print the current document.

Command-S : Save the current document.

Command-T : Open a new tab.

Command-W : Close the front window. To close all windows of the app, press Option-Command-W.

Option-Command-Esc : Force quit an app.

Command–Space bar : Show or hide the Spotlight search field. To perform a Spotlight search from a Finder window, press Command–Option–Space bar. (If you use multiple input sources to type in different languages, these shortcuts change input sources instead of showing Spotlight. Learn how to change a conflicting keyboard shortcut .)

Control–Command–Space bar : Show the Character Viewer, from which you can choose emoji and other symbols .

Control-Command-F : Use the app in full screen, if supported by the app.

Space bar : Use Quick Look to preview the selected item.

Command-Tab : Switch to the next most recently used app among your open apps.

Command–Grave accent (`): Switch between the windows of the app you're using. (The character on the second key varies by keyboard. It's generally the key above the Tab key and to the left of the number 1.)

Shift-Command-5 : In macOS Mojave or later , take a screenshot or make a screen recording. Or use Shift-Command-3 or Shift-Command-4 for screenshots. Learn more about screenshots .

Shift-Command-N: Create a new folder in the Finder.

Command-Comma (,) : Open preferences for the front app.

You might need to press and hold some of these shortcuts for slightly longer than other shortcuts. This helps you to avoid using them unintentionally.

Power button : Press to turn on your Mac or wake it from sleep. Press and hold for 1.5 seconds to put your Mac to sleep.* Continue holding to force your Mac to turn off.

Control–Command–Power button :* Force your Mac to restart, without prompting to save any open and unsaved documents.

Control-Command-Q : Immediately lock your screen.

Shift-Command-Q : Log out of your macOS user account. You will be asked to confirm. To log out immediately without confirming, press Option-Shift-Command-Q.

* Does not apply to the Touch ID sensor .

Command-D : Duplicate the selected files.

Command-E : Eject the selected disk or volume.

Command-F : Start a Spotlight search in the Finder window.

Command-I : Show the Get Info window for a selected file.

Command-R : (1) When an alias is selected in the Finder: show the original file for the selected alias. (2) In some apps, such as Calendar or Safari, refresh or reload the page. (3) In Software Update, check for software updates again.

Shift-Command-C : Open the Computer window.

Shift-Command-D : Open the desktop folder.

Shift-Command-F : Open the Recents window, showing all of the files you viewed or changed recently.

Shift-Command-G : Open a Go to Folder window.

Shift-Command-H : Open the Home folder of the current macOS user account.

Shift-Command-I : Open iCloud Drive.

Shift-Command-K : Open the Network window.

Option-Command-L : Open the Downloads folder.

Shift-Command-N: Create a new folder.

Shift-Command-O : Open the Documents folder.

Shift-Command-P : Show or hide the Preview pane in Finder windows.

Shift-Command-R : Open the AirDrop window.

Shift-Command-T : Show or hide the tab bar in Finder windows.

Control-Shift-Command-T : Add selected Finder item to the Dock (OS X Mavericks or later)

Shift-Command-U : Open the Utilities folder.

Option-Command-D : Show or hide the Dock.

Control-Command-T : Add the selected item to the sidebar (OS X Mavericks or later).

Option-Command-P : Hide or show the path bar in Finder windows.

Option-Command-S : Hide or show the Sidebar in Finder windows.

Command–Slash (/) : Hide or show the status bar in Finder windows.

Command-J : Show View Options.

Command-K : Open the Connect to Server window.

Control-Command-A : Make an alias of the selected item.

Command-N : Open a new Finder window.

Option-Command-N : Create a new Smart Folder.

Command-T : Show or hide the tab bar when a single tab is open in the current Finder window.

Option-Command-T : Show or hide the toolbar when a single tab is open in the current Finder window.

Option-Command-V : Move the files in the Clipboard from their original location to the current location.

Command-Y : Use Quick Look to preview the selected files.

Option-Command-Y : View a Quick Look slideshow of the selected files.

Command-1 : View the items in the Finder window as icons.

Command-2 : View the items in a Finder window as a list.

Command-3 : View the items in a Finder window in columns.

Command-4 : View the items in a Finder window in a gallery.

Command–Left Bracket ([) : Go to the previous folder.

Command–Right Bracket (]) : Go to the next folder.

Command–Up Arrow : Open the folder that contains the current folder.

Command–Control–Up Arrow : Open the folder that contains the current folder in a new window.

Command–Down Arrow : Open the selected item.

Right Arrow : Open the selected folder. This works only when in list view.

Left Arrow : Close the selected folder. This works only when in list view.

Command-Delete : Move the selected item to the Trash.

Shift-Command-Delete : Empty the Trash.

Option-Shift-Command-Delete : Empty the Trash without confirmation dialog.

Command–Brightness Down : Turn video mirroring on or off when your Mac is connected to more than one display.

Option–Brightness Up : Open Displays preferences. This works with either Brightness key.

Control–Brightness Up or Control–Brightness Down : Change the brightness of your external display, if supported by your display.

Option–Shift–Brightness Up or Option–Shift–Brightness Down : Adjust the display brightness in smaller steps. Add the Control key to this shortcut to make the adjustment on your external display, if supported by your display.

Option–Mission Control : Open Mission Control preferences.

Command–Mission Control : Show the desktop.

Control–Down Arrow : Show all windows of the front app.

Option–Volume Up : Open Sound preferences. This works with any of the volume keys.

Option–Shift–Volume Up or Option–Shift–Volume Down : Adjust the sound volume in smaller steps.

Option–Keyboard Brightness Up : Open Keyboard preferences. This works with either Keyboard Brightness key.

Option–Shift–Keyboard Brightness Up or Option–Shift–Keyboard Brightness Down : Adjust the keyboard brightness in smaller steps.

Option key while double-clicking : Open the item in a separate window, then close the original window.

Command key while double-clicking : Open a folder in a separate tab or window.

Command key while dragging to another volume : Move the dragged item to the other volume, instead of copying it.

Option key while dragging : Copy the dragged item. The pointer changes while you drag the item.

Option-Command while dragging : Make an alias of the dragged item. The pointer changes while you drag the item.

Option-click a disclosure triangle : Open all folders within the selected folder. This works only when in list view.

Command-click a window title : See the folders that contain the current folder.

Learn how to use Command or Shift to select multiple items in the Finder .

Click the Go menu in the Finder menu bar to see shortcuts for opening many commonly used folders, such as Applications, Documents, Downloads, Utilities, and iCloud Drive.

The behavior of these shortcuts may vary with the app you're using.

Command-B : Boldface the selected text, or turn boldfacing on or off.

Command-I : Italicize the selected text, or turn italics on or off.

Command-K : Add a web link.

Command-U : Underline the selected text, or turn underlining on or off.

Command-T : Show or hide the Fonts window.

Command-D : Select the Desktop folder from within an Open dialog or Save dialog.

Control-Command-D : Show or hide the definition of the selected word.

Shift-Command-Colon (:) : Display the Spelling and Grammar window.

Command-Semicolon (;) : Find misspelled words in the document.

Option-Delete : Delete the word to the left of the insertion point.

Control-H : Delete the character to the left of the insertion point. Or use Delete.

Control-D : Delete the character to the right of the insertion point. Or use Fn-Delete.

Fn-Delete : Forward delete on keyboards that don't have a Forward Delete key. Or use Control-D.

Control-K : Delete the text between the insertion point and the end of the line or paragraph.

Fn–Up Arrow : Page Up: Scroll up one page.

Fn–Down Arrow : Page Down: Scroll down one page.

Fn–Left Arrow: Home: Scroll to the beginning of a document.

Fn–Right Arrow : End: Scroll to the end of a document.

Command–Up Arrow : Move the insertion point to the beginning of the document.

Command–Down Arrow : Move the insertion point to the end of the document.

Command–Left Arrow : Move the insertion point to the beginning of the current line.

Command–Right Arrow : Move the insertion point to the end of the current line.

Option–Left Arrow : Move the insertion point to the beginning of the previous word.

Option–Right Arrow : Move the insertion point to the end of the next word.

Shift–Command–Up Arrow : Select the text between the insertion point and the beginning of the document.

Shift–Command–Down Arrow : Select the text between the insertion point and the end of the document.

Shift–Command–Left Arrow : Select the text between the insertion point and the beginning of the current line.

Shift–Command–Right Arrow : Select the text between the insertion point and the end of the current line.

Shift–Up Arrow : Extend text selection to the nearest character at the same horizontal location on the line above.

Shift–Down Arrow : Extend text selection to the nearest character at the same horizontal location on the line below.

Shift–Left Arrow : Extend text selection one character to the left.

Shift–Right Arrow : Extend text selection one character to the right.

Option–Shift–Up Arrow : Extend text selection to the beginning of the current paragraph, then to the beginning of the following paragraph if pressed again.

Option–Shift–Down Arrow : Extend text selection to the end of the current paragraph, then to the end of the following paragraph if pressed again.

Option–Shift–Left Arrow : Extend text selection to the beginning of the current word, then to the beginning of the following word if pressed again.

Option–Shift–Right Arrow : Extend text selection to the end of the current word, then to the end of the following word if pressed again.

Control-A : Move to the beginning of the line or paragraph.

Control-E : Move to the end of a line or paragraph.

Control-F : Move one character forward.

Control-B : Move one character backward.

Control-L : Center the cursor or selection in the visible area.

Control-P : Move up one line.

Control-N : Move down one line.

Control-O : Insert a new line after the insertion point.

Control-T : Swap the character behind the insertion point with the character in front of the insertion point.

Command–Left Curly Bracket ({) : Left align.

Command–Right Curly Bracket (}) : Right align.

Shift–Command–Vertical bar (|) : Center align.

Option-Command-F : Go to the search field.

Option-Command-T : Show or hide a toolbar in the app.

Option-Command-C : Copy Style: Copy the formatting settings of the selected item to the Clipboard.

Option-Command-V : Paste Style: Apply the copied style to the selected item.

Option-Shift-Command-V : Paste and Match Style: Apply the style of the surrounding content to the item pasted within that content.

Option-Command-I : Show or hide the inspector window.

Shift-Command-P : Page setup: Display a window for selecting document settings.

Shift-Command-S : Display the Save As dialog, or duplicate the current document.

Shift–Command–Minus sign (-) : Decrease the size of the selected item.

Shift–Command–Plus sign (+) : Increase the size of the selected item. Command–Equal sign (=) performs the same function.

Shift–Command–Question mark (?) : Open the Help menu.

To use these vision shortcuts, first choose Apple menu  > System Settings (or System Preferences), then click Keyboard. Click Keyboard Shortcuts, select Accessibility on the left, then select “Invert colors” and "Contrast" on the right.

Control-Option-Command-8 : Invert colors.

Control-Option-Command-Comma (,) and Control-Option-Command-Period (.) : Reduce contrast and increase contrast.

Use these shortcuts to change keyboard focus. To use some of these shortcuts, first choose Apple menu  > System Settings (or System Preferences), then click Keyboard. Click Keyboard Shortcuts, select Keyboard on the left, then select the shortcut's setting on the right.

Control-F2 or Fn-Control-F2: Move focus to the menu bar. You can then use the arrow keys to navigate the menu, press Return to open a selected menu or choose a selected menu item, or type the menu item's name to jump to that item in the selected menu.

Control-F3 or Fn-Control-F3 : Move focus to the Dock.

Control-F4 or Fn-Control-F4 : Move focus to the active window or next window.

Control-F5 or Fn-Control-F5 : Move focus to the window toolbar.

Control-F6 or Fn-Control-F6: Move focus to the floating window.

Control-Shift-F6 : Move focus to the previous panel.

Control-F7 or Fn-Control-F7 : Change the way Tab moves focus—between navigation of all controls on the screen, or only text boxes and lists.

Control-F8 or Fn-Control-F8 : Move focus to the status menu in the menu bar

Command–Grave accent (`) : Activate the next open window in the front app.

Shift–Command–Grave accent (`) : Activate the previous open window in the front app

Option–Command–Grave accent (`) : Move the focus to the window drawer.

Tab and Shift-Tab : Move to next control, move to previous control.

Control-Tab : Move to the next control when a text field is selected.

Control-Shift-Tab : Move to the previous grouping of controls.

Arrow keys : Move to the adjacent item in a list, tab group, or menu, or move sliders and adjusters (Up Arrow to increase values, Down Arrow to decrease values)

Control–Arrow keys : Move to a control adjacent to the text field.

Other accessibility shortcuts:

Option-Command-F5 or triple-press Touch ID : Show the Accessibility Shortcuts panel .

VoiceOver commands

Zoom in or out

Use Mouse Keys to control the pointer with your keyboard

If you're using VoiceOver, you might need to make VoiceOver ignore the next key press before you can use some of the shortcuts in this article.

Safari shortcuts

Spotlight shortcuts

Mail shortcuts

Photos shortcuts

Disk Utility shortcuts

Preview shortcuts

Apple Music shortcuts

Startup shortcuts

For more shortcuts, check the shortcut abbreviations shown in the menus of your apps. Every app can have its own shortcuts, and shortcuts that work in one app might not work in another.

Use emoji and symbols

Create your own shortcuts and resolve conflicts between shortcuts

Change the behavior of the function keys or modifier keys

Use a spoken command for a keyboard shortcut

ios safari window open _blank not working

Explore Apple Support Community

Find what’s been asked and answered by Apple customers.

COMMENTS

  1. window.open ('', '_blank') doesn't open new tab on iOS only

    I found this question and answer, which seems to be the same problem - but I am new to Javascript and not exactly sure how to implement it: window.open(url, '_blank'); not working on iMac/Safari. So my first question is, am I right in thinking the question and answer I just mentioned could be the same problem?

  2. window.open (url, '_blank'); not working on iMac/Safari

    The correct syntax is window.open(URL,WindowTitle,'_blank') All the arguments in the open must be strings. They are not mandatory, and window can be dropped. So just newWin=open() works as well, if you plan to populate newWin.document by yourself. BUT you MUST use all the three arguments, and the third one set to '_blank' for opening a new true window and not a tab.

  3. [SOLVED] Window.open() doesn't work in Safari in iPhone

    window.open() doesn't work in safari in iPhone. "Doesn't work" means it does not open a window when it is called. Nothing happens. It works in Safari in iPad. It works in Safari in desktop. It works in chrome in anywhere. Has anybody addressed this problem yet?

  4. [Safari 14]window.open with parameters wi…

    Command-click not opening new tab in Safari In Safari, when I do 'Command-Click' on a link inside a web page, it should open up the linked page in a new tab. And it does, except for one particular website (ctvnews.ca) - for this site, the linked page replaces the original page, just as if I had done a simple Click.

  5. my iphone safari opens on a white blank p…

    Tap Clear History and Data to confirm. Turn on JavaScript. Turn on JavaScript if it's not already on. Go to Settings > Safari > Advanced. Find the JavaScript feature. Tap the button to turn on JavaScript." We hope this helps you. Take care! my iphone safari opens on a white blank page for a few seconds and then closes.

  6. Safari screen is totally blank and white.

    Try to start up from macOS Recovery. "If your Mac seems to be turned on but the screen remains blank, follow 'the appropriate steps' depending on whether you're using a. Mac with Apple silicon. If you're not sure, you can try it both ways." IF at the end of these articles, there is no apparent remedy.

  7. [SOLVED] Window.open does not work on ios safari

    the red button at the top is easiest to test, but there are a few. mainly the share buttons on the game over screen. alright, the solution is found! apparently it does not work when called after a button press, but it does work when called through an event. The buttons in our example are sprites that fire an event when clicked on, while our ...

  8. Don't Use The Target="_Blank" Link Attribute In These Cases

    Using the _blank link attribute will cause the link to open in a new browser window or tab. But it is not as straightforward as it seems. It turns out that not only is the _blank link attribute a ...

  9. If Safari isn't loading websites or quits on your iPhone, iPad, or iPod

    Connect to a different network. Try to load a website, like www.apple.com, using cellular data. If you don't have cellular data, connect to a different Wi-Fi network, then load the website. If you're using a VPN (Virtual Private Network), check your VPN settings. If you have a VPN turned on, some apps or websites might block content from loading.

  10. Window.open with ios for an async function not working

    Opening safari works well on iOS 16.2 with window.open, as long as it's not in an async function. In the code I provided, opening safari works, it just does so on user action. The plugins you provided uses inApp browser, and I can't use that. I really feel like it's an issue with Ionic itself.

  11. Window: open() method

    When window.open() returns, the window always contains about:blank. The actual fetching of the URL is deferred and starts after the current script block finishes executing. The window creation and the loading of the referenced resource are done asynchronously. Modern browsers have strict popup blocker policies.

  12. target="_blank" not working on IOS17 safari

    When browsing in safari, it often loads blank pages (iPhone 8 plus and iPad Pro 11") but the page can be seen when using reader view. Why does this happen? On the iPad Pro safari also loads some web pages so that only the left part of the page can be seen. This is also fixed through reader view.

  13. window.open() with _system does not work with wkwebview (on cordova-ios

    I found that using window.open() inside a synchronous click event handler works, but if the window.open() is called asynchronously (e.g. in an Angular rxjs observable), then it is blocked.. This blocking behavior can be tested when you attach the Safari devtools, and then try to run window.open() from the Console, it will also return null.However, if you attach a click event listener to any ...

  14. window.open () functionality is not working in safari browser

    I am using window.open() functionality to open the Url in a popup window, it is working in Chrome, but it's not in Safari browser, are there any settings to open the window as a separate popup or any ... window.open(url, '_blank'); not working on iMac/Safari, ... - Ghost. Jul 4, 2023 at 14:36. is this safari on Mac or on iOS?... and how are ...

  15. Page.open doesn't work on iOS · Issue #14865 · vaadin/flow

    Description of the bug. Page.open dosen't work on iOS. This is probably due to Safari's restrictions on calling window.open from an asynchronous context:

  16. If Safari doesn't open a page or work as expected on your Mac

    From the menu bar in Safari, choose View > Reload Page. Or press Command-R. If Safari doesn't reload the page, quit Safari, then try again. If Safari doesn't quit, you can press Option-Command-Esc to force Safari to quit. If Safari automatically reopens unwanted pages, quit Safari, then press and hold the Shift key while opening Safari.

  17. javascript

    The reason of it is Safari's built-in pop-up blockers. The only javascript that is allowed to open a new window in Safari - is javascript directly attached to user's event. In your case, you're calling window.open later. The workaround here can be: to create a window without a URL in onEditClicked method. safariWindow = window.open();

  18. Safari won't open new links in new tab

    All links open into empty windows on Safari. Hi, I've had this issue for a while and its getting really annoying. Whenever I click on any link, it does open into a new tab (I can see the URL) however when I click on the new tab it shows me a blank start page instantly. I've tried changing my system prefs but nothing helps :(

  19. If you can't open a Safari window on Mac

    If you can't open Safari or a new Safari window, try these suggestions. Make sure you're using the latest versions of Safari and macOS. To check for a Safari or macOS update, choose Apple menu > System Preferences, then click Software Update. See Keep your Mac up to date. Check your startup disk using Disk Utility. If the other suggestions ...

  20. AMP Html not working on iphone safari browser to go new window

    window.open('', '_blank') doesn't open new tab on iOS only Hot Network Questions How to protect a country with no army, no police, no guards, no military authority?

  21. BUG Safari 17.1: Open new window instead …

    Command-click not opening new tab in Safari In Safari, when I do 'Command-Click' on a link inside a web page, it should open up the linked page in a new tab. And it does, except for one particular website (ctvnews.ca) - for this site, the linked page replaces the original page, just as if I had done a simple Click.

  22. Mac keyboard shortcuts

    Finder and system shortcuts. Command-D: Duplicate the selected files.. Command-E: Eject the selected disk or volume.. Command-F: Start a Spotlight search in the Finder window.. Command-I: Show the Get Info window for a selected file.. Command-R: (1) When an alias is selected in the Finder: show the original file for the selected alias.(2) In some apps, such as Calendar or Safari, refresh or ...