Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Ethan Anwar on Jun 16, 2009 05:54
open dhtmlx forum
dhtmlxToolbar for a virtual brower

Okay so we can get a web page to load into a dhtmlxWindow. But once I click on a link or just move to another page i cannot go back.
I would want to make a simple toolbar with 3 buttons. Previous, Refresh and Next.(maybe a Bookmark ?)
Could you be so kind as to show me the onclick() code i'd have to attach to each button?
How cand i refresh just the page within the dhtmlxwindow and not the whole page?same goes for the prev and next buttons.
And btw you can use this idea and make a full browser toolbar.. like the one in the text editor for your future releses.
Answer posted by Alex (support) on Jun 16, 2009 10:01

Hello,

To implement previous,refresh and next buttons you can use some array where window iframe src are placed.

There is onContentLoaded event. It calls when you the iframe content is loaded - so, you can use it to get iframe src:

fl = false;
index = 0;
dhxWins.attachEvent("onContentLoaded",function(win){
 if(fl) return;
  index = arr.length;
  arr[index] = win._frame.src;
 fl = true
})

To reload the window. You can use the following method:

function loadURL(url){

fl = false;

if(win._iframe) win._frame.src = url;

else win.attachURL(url);

}




Answer posted by Ethan ANwar on Jun 27, 2009 03:55

function loadURL(url){

fl = false;

if(win._iframe) win._frame.src = url;

else win.attachURL(url);

}

is it win._frame or win._iframe? or are they 2 seperate things?
Answer posted by Ethan ANwar on Jun 27, 2009 03:57
Sorry for the double post but i was also wondering what variable is fl ?
Answer posted by Ethan Anwar on Jun 27, 2009 05:00
And it doesn't work
Here's my code
i'm just testing the onContentLoaded eventhandler

function zGoogle() {
     w4 = dhxWins.createWindow("w4", 200, 150, 400, 350);

    var bar = w4.attachToolbar();

bar.addButton("forrward", 0, "Forrward", "");
bar.addButton("refresh", 0, "Refresh", "");
bar.addButton("back", 0, "Back", "");
bar.attachEvent("onClick", function(id){browsePage(id);});

    w4.setText("Google");
   w4.attachURL("http://www.google.com/");
w4.attachEvent("onContentLoaded", function(w4){alert('testing');});

    }

I just want an alert onContentLoaded but nothing. The toolbar is attached, the URL is attached but no alert nce the page loads or when i go to another page

Answer posted by Ethan ANwar on Jun 27, 2009 05:44
Sorry.. last one.. i got it working somehow but arr[index] is always the value that i set with attachURL so it always alerts me the same site - http://www.google.com

    function zGoogle() {
     w4 = dhxWins.createWindow("w4", 200, 150, 400, 350);


    var bar = w4.attachToolbar();

bar.addButton("inainte", 0, "Inainte", "");
bar.addButton("refresh", 0, "Refresh", "");
bar.addButton("inapoi", 0, "Inapoi", "");

bar.attachEvent("onClick", function(id){browsePage(id);});

    w4.setText("Google");

   w4.attachURL("http://www.google.com/");


    }
   
index = 0;
var arr= new Array();
dhxWins.attachEvent("onContentLoaded",function(w4){

  index = arr.length;
  arr[index] = w4._frame.src;

alert(arr[index]);

});
Answer posted by Alex (support) on Jun 29, 2009 06:19
>>Sorry for the double post but i was also wondering what variable is fl ?
It was a typo, sorry for convenience, correct code will be 
     if(win._frame) win._frame.src = url;

win._frame points to inner content frame 
Answer posted by Alex (support) on Jun 29, 2009 06:28

>> i got it working somehow but arr[index] is always the value that i set with attachURL so it always alerts me the same site - http://www.google.com

Problem caused by cross-domain security.
It prevents communication between objects, which were loaded from different domains. So, master script can't access the objects loaded from different domain, including full url of the page, which was set from inside iframe's content

Answer posted by Ethan Anwar on Jun 29, 2009 10:19
>> It prevents communication between objects, which were loaded from different domains. So, master script can't access the objects loaded from different domain, including full url of the page, which was set from inside iframe's content

So what you're saying is that there's no way i ca do this, i cannot emulate browser behavior inside a window?
Answer posted by Alex (support) on Jun 30, 2009 01:35
Yes, it doesn't possible to fully emulate browser behavior - because of reason described in the previous answer.