Html open windows directory

Форум

Справочник

window.open

Синтаксис

Аргументы

Описание, примеры

Метод open создает новое окно браузера , аналогично команде «Новое окно» в меню браузера. Обычно это не вкладка, а именно новое окно, но в некоторых браузерах можно настроить то или иное поведение явным образом.

Если параметр strUrl — пустая строка, то в окно будет загружен пустой ресурс about:blank.

В любом случае, загрузка осуществляется асинхронно. Создается пустое окно, загрузка ресурса в которое начнется уже после завершения исполнения текущего блока кода.

Связь между окнами

Метод open возвращает ссылку на новое окно, которая служит для обращения к нему и вызову его методов, если это соответствует ограничениям безопасности Same Origin.

Если окно с именем winName уже существует, то вместо открытия нового окна, strUrl загружается в существующее, ссылка на которое возвращается. При этом строка параметров не применяется.

В случае, когда окно открыть не удалось, например, оно заблокировано штатными Popup-blocker’ами Firefox/IE — вызов open вернет null.
Проверяйте его, если не хотите лишних ошибок в своих скриптах.

Указание пустого strUrl для существующего имени окна — удобный способ получить ссылку на это окно без его перезагрузки.

Если вы хотите открывать новое окно при каждом вызове open() — используйте для winName специальное значение ‘_blank’.

Строка параметров

Необязательная строка параметров состоит из списка разделенных запятой настроек нового окна. После открытия окна их уже нельзя будет изменить.

Если строки параметров нет или она пустая, то для нового окна будут взяты параметры по умолчанию.

Если строка параметров указана, то не перечисленные в ней параметры будут отключены(кроме titlebar/close). Поэтому включите в ней свойства, которые нужны.

Если в параметрах не указаны размеры, то новое окно будет по размеру такое же, как последнее открытое.

Если не указана позиция нового окна, то оно откроется со сдвигом в 20-30 пикселей (зависит от браузера) от последнего открытого окна.
Такой сдвиг позволяет посетителю заметить, что открылось новое окно.
Если текущее окно максимизировано, то сдвига не будет: новое тоже будет максимизировано.

Основные кроссбраузерные параметры

Параметры, касающиеся элементов управления окна, могут быть жестко установлены в конфигурации браузера. В этом случае их указание в параметрах open() не даст нужного эффекта.

left/top Расстояние от левой/верхней границы окна операционной системы до границы нового окна. Новое окно не может быть создано за границами экрана height/width Высота/ширина в пикселях внутренности нового окна, включая полосы прокрутки, если они есть. Минимальное значение: 100 menubar Если этот параметр установлен в yes, то в новом окне будет меню. toolbar Если этот параметр установлен в yes, то в новом окне будет навигация (кнопки назад, вперед и т.п.) и панель вкладок location Если этот параметр установлен в yes, то в новом окне будет адресная строка directories Если этот параметр установлен в yes, то в новом окне будут закладки/избранное status Если этот параметр установлен в yes, то в новом окне будет строка состояния resizable Если этот параметр установлен в yes, то пользователь сможет изменить размеры нового окна. Рекомендуется всегда устанавливать этот параметр. scrollbars Если этот параметр установлен в yes, то новое окно при необходимости сможет показывать полосы прокрутки

Читайте также:  Управление кнопкой питания windows 10

What are the ways to make an html link open a folder

I need to let users of an application open a folder by clicking a link inside a web page. The path of the folder is on the network and can be accessed from everywhere. I’m probably sure there is no easy way to do this, but maybe I’m mistaken?

9 Answers 9

Do you want to open a shared folder in Windows Explorer? You need to use a file: link, but there are caveats:

  • Internet Explorer will work if the link is a converted UNC path ( file://server/share/folder/ ).
  • Firefox will work if the link is in its own mangled form using five slashes ( file://///server/share/folder ) and the user has disabled the security restriction on file: links in a page served over HTTP. Thankfully IE also accepts the mangled link form.
  • Opera, Safari and Chrome can not be convinced to open a file: link in a page served over HTTP.

The URL file://[servername]/[sharename] should open an explorer window to the shared folder on the network.

make sure your folder permissions are set so that a directory listing is allowed then just point your anchor to that folder using chmod 701 (that might be risky though) for example

make sure that you have no index.html any index file on that directory

Using file:///// just doesn’t work if security settings are set to even a moderate level.

If you just want users to be able to download/view files* located on a network or share you can set up a Virtual Directory in IIS. On the Properties tab make sure the «A share located on another computer» is selected and the «Connect as. » is an account that can see the network location.

Link to the virtual directory from your webpage (e.g. http://yoursite/yourvirtualdir/) and this will open up a view of the directory in the web browser.

*You can allow write permissions on the virtual directory to allow users to add files but not tried it and assume network permissions would override this setting.

Upload a whole directory through an HTML form

Is it possible to upload a folder with a file input in the browser?

I searched and found out that this might be a browser limitation and that I might need to use a Java Applet or Flash.

8 Answers 8

It’s becoming possible with use of webkitdirectory.

Supported since Firefox 50, Chrome 30, Safari 11.1, Edge 14, but not on most mobile browsers as of 2019: https://caniuse.com/#feat=input-file-directory

Please Try This for upload the folder :

It is possible to upload multiple files at a time, by drag and drop, without any browser plugins. This is a new development with HTML5 and javascript, so you’ll probably need a fallback for older browsers.

Читайте также:  Синхронизация яндекс почты с почтой windows 10

It’s called «HTML5 drag and drop». I’ve not used it yet, so I can’t give you sample code, but searching for that phrase, and reading the linked Mozilla Blog article may give you some pointers.

It doesn’t seem possible to upload a folder by only using PHP but Javascript can detect folders so I solved it by doing these two steps:

Create a Javascript function that reads the directory and files that will be uploaded and add this to a array(I called this Filestructure) that will be sent together with POST. For example:

There is a similar function in Dropzone.js that already handles this that I had to modify (_addFilesFromDirectory() ). But you can create your own function to do this. See this https://stackoverflow.com/a/20431117/6760554 if you need more help regarding this.

In Php you should first let your files be uploaded to a certain folder where they will be stored temporary. After your files has been uploaded you then need to pass your javascript array to your phpcode. There you need to iterate the array and create the folders and then move your uploaded files from the temporary folder to their respective location. For example:

How to download HTTP directory with all files and sub-directories as they appear on the online files/folders list?

There is an online HTTP directory that I have access to. I have tried to download all sub-directories and files via wget . But, the problem is that when wget downloads sub-directories it downloads the index.html file which contains the list of files in that directory without downloading the files themselves.

Is there a way to download the sub-directories and files without depth limit (as if the directory I want to download is just a folder which I want to copy to my computer).

8 Answers 8

  • It will download all files and subfolders in ddd directory
  • -r : recursively
  • -np : not going to upper directories, like ccc/…
  • -nH : not saving files to hostname folder
  • —cut-dirs=3 : but saving it to ddd by omitting first 3 folders aaa, bbb, ccc
  • -R index.html : excluding index.html files

I was able to get this to work thanks to this post utilizing VisualWGet. It worked great for me. The important part seems to be to check the -recursive flag (see image).

Also found that the -no-parent flag is important, othewise it will try to download everything.

‘-r’ ‘—recursive’ Turn on recursive retrieving. See Recursive Download, for more details. The default maximum depth is 5.

‘-np’ ‘—no-parent’ Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded. See Directory-Based Limits, for more details.

‘-nH’ ‘—no-host-directories’ Disable generation of host-prefixed directories. By default, invoking Wget with ‘-r http://fly.srk.fer.hr/’ will create a structure of directories beginning with fly.srk.fer.hr/. This option disables such behavior.

‘—cut-dirs=number’ Ignore number directory components. This is useful for getting a fine-grained control over the directory where recursive retrieval will be saved.

Читайте также:  Windows 10 автоматический вход после спящего режима

Open directory dialog

I want the user to select a directory where a file that I will then generate will be saved. I know that in WPF I should use the OpenFileDialog from Win32, but unfortunately the dialog requires file(s) to be selected — it stays open if I simply click OK without choosing one. I could «hack up» the functionality by letting the user pick a file and then strip the path to figure out which directory it belongs to but that’s unintuitive at best. Has anyone seen this done before?

15 Answers 15

You can use the built-in FolderBrowserDialog class for this. Don’t mind that it’s in the System.Windows.Forms namespace.

If you want the window to be modal over some WPF window, see the question How to use a FolderBrowserDialog from a WPF application.

EDIT: If you want something a bit more fancy than the plain, ugly Windows Forms FolderBrowserDialog, there are some alternatives that allow you to use the Vista dialog instead:

Third-party libraries, such as Ookii dialogs (.NET 4.5+)

Note that this dialog is not available on operating systems older than Windows Vista, so be sure to check CommonFileDialog.IsPlatformSupported first.

I created a UserControl which is used like this:

The xaml source looks like this:

and the code-behind

Ookii folder dialog can be found at Nuget.

PM> Install-Package Ookii.Dialogs.Wpf

And, example code is as below.

I’m using Ookii dialogs for a while and it work nice for WPF.

Here’s the direct page:

For those who don’t want to create a custom dialog but still prefer a 100% WPF way and don’t want to use separate DDLs, additional dependencies or outdated APIs, I came up with a very simple hack using the Save As dialog.

No using directive needed, you may simply copy-paste the code below !

It should still be very user-friendly and most people will never notice.

The idea comes from the fact that we can change the title of that dialog, hide files, and work around the resulting filename quite easily.

It is a big hack for sure, but maybe it will do the job just fine for your usage.

In this example I have a textbox object to contain the resulting path, but you may remove the related lines and use a return value if you wish.

The only issues with this hack are :

  • Acknowledge button still says «Save» instead of something like «Select directory», but in a case like mines I «Save» the directory selection so it still works.
  • Input field still says «File name» instead of «Directory name», but we can say that a directory is a type of file.
  • There is still a «Save as type» dropdown, but its value says «Directory (*.this.directory)», and the user cannot change it for something else, works for me.

Most people won’t notice these, although I would definitely prefer using an official WPF way if microsoft would get their heads out of their asses, but until they do, that’s my temporary fix.

Оцените статью