../Window(s) webview/F.A.Q.Home
WebView: F.A.Q.
..a.k.a. Frequently Asked Questions, or not so frequently, just a place to collect any trick, "hack", or script applied to the webview, ordered by subject:
  • Document texts »Changing the webview's font style.
    »Changing specific text element, like the selected file name.
    »Changing basic sentences, like "Select an item to view its description.".
  • WvLeft »Changing the panel background.
    »Changing the panel background color.
    »Changing the panel background repeat method.
  • WvLine »Changing the Line.
    »Changing the width and height of the Line.
    »Removing the line without leaving a blank space.
  • Folder icon »Changing the icon size.
    »Removing the Folder icon.
    »Adding the folder icon preview to the MiniBanner (98 only).
  • MiniBanner (98 only) »Adding a background image/color to the MiniBanner.
    »Adding the folder icon preview to the MiniBanner.
  • Links »Adding links to the Left Info Panel.
    »Changing the links style.
    »Linking to other (special) folders.
  • Thumbnail »Enabling the media (sound and movie) preview.
    »Changing the Thumbnail size.
    »Removing the white square shown in my computer.
  • File details »Changing the maximum number of displayed selected files.
    »Accessing the Date Last Accessed/Last Modified/Created file attributes (Me only).
    »Listing the Selected file verbs (available actions) (Me only).
    »Adding a TextFile preview (98).
    »Adding a TextFile preview (Me).
    »Creating a bordered detail zone.
  • General appearance »Adding colored scrollbars to the left info panel.
    »Setting filters to the webview content, such as fading effects.
    »Adding a background sound to the folder.
  • General layout »Moving all the Panel elements.
    »Editing the FileList/Panel proportion.
    »Inverting the webview (Moving the panel to the right).
    »Resizing the FileList the way you want.
    »Setting the FileList view type using webview.
  • Protection »Protecting the folder by a password using the webview.
    »Removing the windows and windows/system warning screens.
  • Scripting »Accessing special variables by scripting.
    »Deselecting all Files.
    »Deselecting all Files except one.
    »Renaming a file.
    »Creating a folder.
    »Copying/Cuting/Moving files.
    »Selecting certain files.
    »Listing all items in the current folder.
    »Download some cool scripts to use in your webviews.
    »Completly customise the folder's output.
  • Related
If you know any cool ones, please . More to come. All Scripts using CreateObject have a confirmation dialog, more info here.
 
Document texts
Changing the webview's font style:
To change the font style of an element, go to its reference (ex: #Body, #Details...) in the style sheet, <style></style> in 98 or Me, and edit between the curly braces. You can figure out what does what, but for more check the W3School.

Changing specific text element, like the selected file name:
As they are dynamically created the selected file attributes have no reference in the style sheet (it could though), so we have to directly edit the script, and if you want add a style class to it.

Go were it is created [in 98 or Me] and edit the html around the variable like "name", "size", "data" etc... As you maybe know ' can be used as a replacement for ", so the string is not interrupted. If you want to make this change easier for later edit, add/replace <span class="something"></span> then add the reference in the stylesheet as: .something {...}

Changing basic sentences, like "Select an item to view its description.":
At the beginning of the script are some quoted sentences you can replace by your own ones. Because some fonts don't use small caps, or accents, you could change these sentences with some that don't use them.
WvLeft
Changing the panel background:
See common editing.

Changing the panel background color:
See common editing.

Changing the panel background repeat method:
See common editing.
WvLine
Changing the Line:
See common editing.

Changing the width and height of the Line:
See common editing.

Removing the line without leaving a blank space:
You just have to delete/comment <!-- --> the <img id=Logoline [...]> line, here in 98 or Me.
Folder icon
Changing the icon size:
Edit the <param name="scale" [...]> param of the folder icon object, here in 98 or Me.

Removing the Folder icon:
Comment or remove the folowing lines (representing the folder icon object) in your folder.htt: <object classid="clsid:E5DF9D10-3B52-11D1-83E8-00A0C90DC849" [...]>
[...]
</object>
Adding the folder icon preview to the MiniBanner (98 only):
You should copy the folder icon object into the MiniBanner code, with some size fixing: insert in the Mini banner just after this text <!-- using a table with nowrap to prevent word wrapping -->
<table><tr><td nowrap>
the lines : <td align="right" valign="top" width="32">
<object classid="clsid:E5DF9D10-3B52-11D1-83E8-00A0C90DC849" width="32">
<param name="scale" value="100">
</object>
</td>
and change the miniHeight variable to 38.
MiniBanner (98 only)
Adding a background image/color to the MiniBanner:
In the MiniBanner inline style, add URL(Pathtofile) after background: window to add a background-image and replace window to change the background color.

Adding the folder icon preview to the MiniBanner:
See folder icon.
Links
Adding links to the Left Info Panel:
In 98 remove the comments around the links in the document body <!-- --> and edit them. In Me add the links inside the Details div (<div id=Details>).

Changing the links style:
Add in the style sheet <style></style> in 98 or Me a style definition for all links (<A> tag). Check here for more info.

Linking to other (special) folders:
You can use links to offline locations. It is possible to take advantage of the special variables that get replaced automaticly: %THISDIRPATH%, %THISDIRNAME% and %TEMPLATEDIR% (the windows/web folder). You can also link through clsid values, check the shortcutting syntax page for more info.
Thumbnail
Enabling the media (sound and movie) preview:
In 98, change the wantMedia variable at the beginning of the script to true. In Me, comment the return false; lines in the IsMovieFile() and IsSoundFile() functions. Cool, but may hinder media file manipulation.

Changing the Thumbnail size:
Go to #Thumbnail in the style sheet <style></style> in 98 or Me, and edit the height and width
Removing the white square shown in my computer:
It's the thumbnail object being shown on load, but with no thumbnail. To fix it add style="display: none" to <object id=" PieChart " ... > in mycomp.htt or any other file.

File details
Changing the maximum number of displayed selected files:
By default a list of a maximum of 16 items is shown when selecting multiple files, change that by replacing the 16 in the if (data <= 16) line in 98 and the if (items <= 16) line in Me.

Accessing the Date Last Accessed/Last Modified/Created file attributes (Me only):
Use this script (places it inside the file attributes access in Me), made by elastic, (the date returned by this property is really big): var fso = new ActiveXObject("Scripting.FileSystemObject");
filedr = fso.GetFolder(item.path) // item.path was defined earlier.
accessed = filedr.DateLastAccessed;
modified = filedr.DateLastModified;
created = filedr.DateCreated;

Listing the Selected file verbs (available actions) (Me only):
Use this function (places it inside the file attributes access in Me): var tv = FileList.SelectedItems().Item(0).Verbs().Count;
  for (i=0; i<=tv; i++) {
    verbName = FileList.SelectedItems().Item(0).Verbs().Item(i).Name;
    amp = verbName.indexOf("&");
    verbName = verbName.substring(0, (amp == 1 ? 1 : amp -1)) + verbName.substring(amp + 1, verbName.length); // Eliminating the '&' character that appears in the actual verb
    text += "<br><a onClick='FileList.SelectedItems().Item(0).Verbs().Item(" + i + ").DoIt()'>" + verbName + "</a>";
  }

Adding a TextFile preview (98):
Edit Folder.htt: 4 parts, first goes in the first <script language="JavaScript"></script> 2nd goes after // erase any visible thumbnail since the selection changed 3rd just before // try to generate a new thumbnail asynchronously Last one goes where you want the text to be shown, most likely just under <span id=Info></span>
  1. function getText() {
        var charnumber=100; //Numbers of caracters shown
        var fso= new ActiveXObject("Scripting.FileSystemObject"); 
        var tf = fso.OpenTextFile(FileList.SelectedItems().Item(0).Path, 1, false); 
        var Read = tf.Read(charnumber);
        Read = Read.replace( /</g, "&lt;"); //Formating the details to prevent html from being interpreted
        Read = Read.replace( />/g, "&gt;");
        textpreview.innerHTML="<br><br>" + Read;
    }
    						
  2. document.all.textpreview.innerHTML = ""; //Removing [preview] text...
    						
  3.     ext = name.substring(name.lastIndexOf(".") + 1, name.length); 
        ext = ext.toLowerCase(); 
        if (ext == 'wri' || ext == 'ini' || ext == 'htt' || ext == 'nfo' 
         || ext == 'die' || ext == 'js' || ext == 'vbs' || ext == 'bat' 
         || ext == 'reg' || ext == 'doc' || ext == 'txt') { //You can add extentions here
            document.all.textpreview.innerHTML = "<br><br><font onclick=getText()>[preview]</font>"; 
        } 
    						
  4. <span id="textpreview"></span>
    						
Adding a TextFile preview (Me):
Edit Folder.htt: 4 parts, first goes at the beginning of the first <script language="JavaScript"></script> 2nd goes after // kill any preview 3rd goes after else if (IsSoundFile(ext)) { [...] } Last one goes where you want the text to be shown, most likely just under "<span id=Info></span>".
  1. function getText() {
        var charnumber=100; //Numbers of caracters shown
        var fso= new ActiveXObject("Scripting.FileSystemObject"); 
        var tf = fso.OpenTextFile(FileList.SelectedItems().Item(0).Path, 1, false); 
        var Read = tf.Read(charnumber);
        Read = Read.replace( /</g, "&lt;"); //Formating the details to prevent html from being interpreted
        Read = Read.replace( />/g, "&gt;");
        textpreview.innerHTML="<br><br>" + Read;
    }
    function IsTextFile(ext) {
        var types = ",wri,ni,htt,nfo,die,js,vbs,bat,reg,doc,txt,"; //You can add extentions here
        var temp = ","+ext+",";
        return types.indexOf(temp) > -1;
    }
    						
  2. document.all.textpreview.innerHTML = ""; //Removing [preview] text...
    						
  3. else if (IsTextFile(ext)) {
        document.all.textpreview.innerHTML = "<br><br><font onclick=getText()>[preview]</font>";
    }
    						
  4. <span id="textpreview"></span>
    						
Creating a bordered detail zone:
Add a Div around <span id=Info><span> like <div id="InfoC"><div> Then add the #InfoC selector in the style sheet <style></style> in 98 or Me, so you can edit the div's style, for example by adding a border and a background.
General appearance
Adding colored scrollbars to the left info panel:
Modify the body selector in the style sheet <style></style> in 98 or Me, by adding scrollbar color definitions, available at WebFx.

Setting filters to the webview content, such as fading effects:
First of all the element must have a relative position position : relative in the stylesheet. Changing this will probably mess up a bit the view, so add a few <br>s just underneath the element. Now add filter: [...] to the inline style of the element, replacing [...] by filters syntax, available here (scroll down a bit...).
Note: Me's webview has a built-in fading effect, enabled automaticly if your computer can support it.

Adding a background sound to the folder:
Add the <bgsound src="source_file_url" loop="loop_number"> tag anywhere in the <head> (or) <body> of the document. source_file_url can be any sound file including mp3, and loop_number is the number of times the file repeats (-1 is infinite).
General layout
Moving all the Panel elements:
In the style sheet <style></style> in 98 or Me, change the p margins in 98 and the #Corner and #Details paddings in Me.

Editing the FileList/Panel proportion:
Under Win98, edit the #FileList selector's left (panel width) and width (fileList width) attributes in percent. Also change the width of #Panel with the same value as the #FileList {left} Under Me/2k/Xp just change the pixel value of #FileList {width} (panel's width).

Inverting the webview (moving the panel to the right):
In Me it's easy: add dir="Rtl" to the html tag.

In 98, prepare for a ride. In the style sheet <style></style> add/replace the following: body {text-align: right} #Filelist {left: 0px} #Panel {left: 70%; width: 30%} #Brand {left: 0px} Replace the FixSize Function by a custom one:
function FixSize() 
{ 
    var largeurfenetre = document.body.clientWidth;
    var hauteurfenetre = document.body.clientHeight;
    var minimumlargeur = 400;
    var hauteurbanner = 32;

    if (largeurfenetre > minimumlargeur) {
        document.all.MiniBanner.style.visibility = "hidden";
        document.all.Panel.style.visibility = "visible";
        document.all.FileList.style.top = 0 ;
        document.all.FileList.style.pixelWidth = largeurfenetre - document.all.Panel.style.pixelWidth ;
        document.all.FileList.style.pixelHeight = hauteurfenetre;
        document.all.Panel.style.pixelHeight = hauteurfenetre ; 
        document.all.MiniBanner.style.position = "absolute"; 
    } else {
        document.all.Panel.style.visibility = "hidden";
        document.all.MiniBanner.style.visibility = "visible";  
        document.all.FileList.style.top = hauteurbanner ;
        document.all.FileList.style.pixelWidth = largeurfenetre ;
        document.all.FileList.style.pixelHeight = hauteurfenetre - hauteurbanner ;
        document.all.MiniBanner.style.pixelHeight = hauteurbanner ; 
        document.all.MiniBanner.style.position = "relative";
    }
    document.all.FileList.style.pixelLeft = 0 ;
}
			
Move the FileList <object id=FileList [...]>[...]</object> before the Panel (just after the body beginning).
Add in the inline scripting,
of the MiniBanner: text-align: left; of the Panel: background-position : top right;

Resizing the FileList the way you want:
The best way to resize the FileList is to set it style properties to {position: absolute; left: left; top: top; width: width; height: height} using any type of values (more info here). Remember to change the other elements properties too.
So in fact, the Resize() or Fixsize() functions used in Windows are quite useless, unless you need to mix some types of values (totalheight - 40px for example). But if you use IE5+ you could also use CSS expressions expression(javascript_expression) to directly resize using css (used in Me in webview.css for example). Also check out a cool artcile on css expression optimisation at WebFX.

Setting the FileList view type using webview:
Theorically this could be done by adding the ViewMode parameter to the FileList object, however I couldn't make this to work: <object id=FileList classid="clsid:1820FED0-473E-11D0-A96C-00C04FD705A2" [...]>
<param name="ViewMode" value="1">
</object>
Defines the view in which the contents of the folder will be displayed (1=Large Icons, 2=Small Icons, 3=List, 4=Details). More FileList parameters here.
Protection
Protecting the folder by a password using the webview:
Not really unbreakable, but still good enough. Add this script at the beginning of the head of the document:
<script language="JavaScript">
    var password = "Password";
    var name = prompt("Prompt text","");
    if (name == password) alert("Good password text")
    else {
        alert("Bad password text");
        window.location.replace("Folder opened if bad password");
    }
</script>
			
To remove the script make a search for "Folder.htt" with hidden files visible, find your file and delete/edit it.

Removing the windows and windows/system warning screens:
If you hate the "welcome" screens for the windows and system folders, open the folder, choose view, click customize this folder and select remove customization. This will get rid of the folder.htt in any folder and remove webview entries in the desktop.ini of the folder.
Less definite way would be to move the folder's desktop.ini file to somewhere else, so you can put it back.
Scripting
Accessing special variables by scripting:
Some variables get replaced automaticly: %THISDIRPATH%, %THISDIRNAME% and %TEMPLATEDIR% (the windows/web folder). Get them in scripts by implanting them in a tag, then on load retrieving the tag's content.
Example: the current folder's path is retrieved in Me by writing %THISDIRPATH% in <span id=Info></span> then adding in the onload function: gFolderPath = Info.innerHTML; With this gFolderPath contains the current folder's path.

Deselecting all files:
Call this function to deselect all files: function deSelectAll() {
FileList.focus();
FileList.SelectItem(FileList.FocusedItem, 4);
FileList.SelectItem(FileList.FocusedItem, 0);
}

Deselecting all Files except one:
Call this function to deselect all files except one with 'id=n' in the SelectedItems() list:
function SelectFile(n) {
    keepItem = document.all.FileList.SelectedItems().Item(n);
    document.all.FileList.SelectItem( keepItem , 4);
    document.all.FileList.SelectItem( keepItem , 1);
	FileList.focus();
}
			

Renaming a file:
The Name propery of an FolderItem object isn't read-only. For example this script will rename the focused file with the content of the 'newname' attribute:
function renameFocusedFile(newname) {
    FileList.FocusedItem.Name = newname;
}
			

Creating a folder:
function createFolder(bName) {
    FileList.Folder.NewFolder(bName)
}
			
Creates a new file with bName as the name of the new folder.

Copying/Cuting/Moving files:
You can copy/cut files by invoking their verbs or by using the CopyHere/MoveHere methods of the Folder object.
    FileList.Folder.CopyHere(vItem) //Copies the vItem file to the current folder.
    FileList.Folder.MoveHere(vItem) //Moves the vItem file to the current folder.
    //vItem can be a file name string, a FolderItem object, or a FolderItems object.
    if (FileList.Folder.SelectedItems().Count == 1) {
        FileList.Folder.CopyHere( FileList.Folder.SelectedItems().Item(0) );
    }//Copies the selected item and pastes it into the current folder.
			

Selecting certain files:
Make a form that allows you to select criterias (I'll let you do that), add onsubmit="selectCR()" to its attributes. Add a new function:
function selectCR() {
    FileList.focus();
    for (i=0; i<FileList.Folder.Items().Count; i++) {
        if (FileList.Folder.Items().Item(i).Name == [add conditions here depending on your form,
                                                         and you could extract part of the name just before]) {
            FileList.SelectItem(FileList.Folder.Items().Item(i), 1);
        }
    }
}
			

Listing all items in the current folder:
content.innerHTML = "";
for (i=0; i<FileList.Folder.Items().Count; i++ ) {
    content.innerHTML += FileList.Folder.Items().Item(i).Name //fake output
}
			

Download some cool scripts to use in your webviews:
WebFX has plenty of them, including html formated tooltips, custom context menus and more.

Completly customise the folder's output:
As you may have noticed you can retrieve all the items in the current folder by scripting. You can then access their properties like name, access date, type etc... this gives tremendous possibilities, allowing you to completely recreate the FileList. The only drawback is the processing time for large folders. We'll start a project on how to do that soon.
Related
Top

xhtml 1.1