当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript webFrame.executeJavaScript方法代码示例

本文整理汇总了TypeScript中electron.webFrame.executeJavaScript方法的典型用法代码示例。如果您正苦于以下问题:TypeScript webFrame.executeJavaScript方法的具体用法?TypeScript webFrame.executeJavaScript怎么用?TypeScript webFrame.executeJavaScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在electron.webFrame的用法示例。


在下文中一共展示了webFrame.executeJavaScript方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

const isUnsafeEvalEnabled = function () {
  return webFrame.executeJavaScript(`(${(() => {
    try {
      new Function('') // eslint-disable-line no-new,no-new-func
    } catch {
      return false
    }
    return true
  }).toString()})()`, false)
}
开发者ID:doridoridoriand,项目名称:electron,代码行数:10,代码来源:security-warnings.ts

示例2: Promise

 return new Promise((resolve) => {
   webFrame.executeJavaScript(`(${(() => {
     try {
       new Function('') // eslint-disable-line no-new,no-new-func
     } catch {
       return false
     }
     return true
   }).toString()})()`, false, resolve)
 })
开发者ID:vwvww,项目名称:electron,代码行数:10,代码来源:security-warnings.ts

示例3:

		return !(require('spellchecker').isMisspelled(text));
	}
});

webFrame.registerURLSchemeAsSecure('app');
webFrame.registerURLSchemeAsBypassingCSP('app');
webFrame.registerURLSchemeAsPrivileged('app');
webFrame.registerURLSchemeAsPrivileged('app', {
	secure: true,
	supportFetchAPI: true,
});

webFrame.insertText('text');

webFrame.executeJavaScript('JSON.stringify({})', false, (result) => {
    console.log(result);
}).then((result: string) => console.log('OK:' + result));

console.log(webFrame.getResourceUsage());
webFrame.clearCache();

// clipboard
// https://github.com/atom/electron/blob/master/docs/api/clipboard.md

clipboard.writeText('Example String');
clipboard.writeText('Example String', 'selection');
console.log(clipboard.readText('selection'));
console.log(clipboard.availableFormats());
clipboard.clear();

clipboard.write({
开发者ID:longlho,项目名称:DefinitelyTyped,代码行数:31,代码来源:github-electron-renderer-tests.ts

示例4:

webFrame.setZoomLevelLimits(50, 200);

webFrame.setSpellCheckProvider('en-US', true, {
	spellCheck: text => {
		return !(require('spellchecker').isMisspelled(text));
	}
});

webFrame.registerURLSchemeAsSecure('app');
webFrame.registerURLSchemeAsBypassingCSP('app');
webFrame.registerURLSchemeAsPrivileged('app');

webFrame.insertText('text');

webFrame.executeJavaScript('JSON.stringify({})', false, (result) => {
    console.log(result);
});

console.log(webFrame.getResourceUsage());
webFrame.clearCache();

// clipboard
// https://github.com/atom/electron/blob/master/docs/api/clipboard.md

clipboard.writeText('Example String');
clipboard.writeText('Example String', 'selection');
console.log(clipboard.readText('selection'));
console.log(clipboard.availableFormats());
clipboard.clear();

clipboard.write({
开发者ID:CNManning,项目名称:DefinitelyTyped,代码行数:31,代码来源:github-electron-renderer-tests.ts

示例5:

 (async () => {
   // `window.opener` is not available when sandbox is activated,
   // therefore we need to fake the function on backend area and
   // redirect the response to a custom protocol
   await webFrame.executeJavaScript(SingleSignOn.javascriptHelper());
 })();
开发者ID:wireapp,项目名称:wire-desktop,代码行数:6,代码来源:preload-sso.ts

示例6: spellCheck

webFrame.setVisualZoomLevelLimits(50, 200)
webFrame.setLayoutZoomLevelLimits(50, 200)

webFrame.setSpellCheckProvider('en-US', {
  spellCheck (words, callback) {
    setTimeout(() => {
      const spellchecker = require('spellchecker')
      const misspelled = words.filter(x => spellchecker.isMisspelled(x))
      callback(misspelled)
    }, 0)
  }
})

webFrame.insertText('text')

webFrame.executeJavaScript('return true;').then((v: boolean) => console.log(v))
webFrame.executeJavaScript('return true;', true).then((v: boolean) => console.log(v))
webFrame.executeJavaScript('return true;', true)
webFrame.executeJavaScript('return true;', true, (result: boolean) => console.log(result))

console.log(webFrame.getResourceUsage())
webFrame.clearCache()

// clipboard
// https://github.com/atom/electron/blob/master/docs/api/clipboard.md

clipboard.writeText('Example String')
clipboard.writeText('Example String', 'selection')
console.log(clipboard.readText('selection'))
console.log(clipboard.availableFormats())
clipboard.clear()
开发者ID:doridoridoriand,项目名称:electron,代码行数:31,代码来源:renderer.ts


注:本文中的electron.webFrame.executeJavaScript方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。