Adobe Dreamweaver API Reference CS5 Uživatelský manuál Strana 373

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 533
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 372
368
DREAMWEAVER API REFERENCE
Dynamic documents
Last updated 8/27/2013
Example 1
Assume that the live view content invokes "GetUserName " and use the value populating text element.
Prior to Dreamweaver 13.1
DW code:
function GetUserName()
{
return "SomeName";
}
liveViewBrowser = document.getElementById('browser');
var liveViewDoc = liveViewBrowser.getWindow().document;
liveViewDoc.GetUserName = GetUserName;
Live view browser (<mm:browsercontrol>) code:
document.getElementById("textelement").innerHTML = document.GetUserName();
Dreamweaver 13.1 and later
DW code:
function GetUserName(getUserNameCallbackFunction)
{
getUserNameCallbackFunction("SomeName");
}
liveViewBrowser = document.getElementById('browser');
var liveViewDoc = liveViewBrowser.getWindow().document;
liveViewDoc.GetUserName = GetUserName;
Live view browser (<mm:browsercontrol>) code:
function getUserNameResult(str)
{
document.getElementById("textelement").innerHTML = str;
}
document.GetUserName(getUserNameResult);
Note: Not all synchronous calls can be changed to asynchronous using the approach explained in the example above. In
some scenarios, you may have to consider reducing round trips between two processes. See the next example for another
approach.
Example 2
In the jquery panel, "loadString" is called from the live view browser (<mm:browsercontrol> Render process) to
Dreamweaver. The actual "loadString" JS function just calls dw.loadString to get the localized strings from the
resource. As this is a one-time initialization, you can pass all the necessary strings as part of initializing live view
browser.
Zobrazit stránku 372
1 2 ... 368 369 370 371 372 373 374 375 376 377 378 ... 532 533

Komentáře k této Příručce

Žádné komentáře