[英]Google Chrome Extension to Edit Visual force page text boxes
I've developed a simple google chrome extension, that edits current page textbox values. 我开发了一个简单的谷歌浏览器扩展程序,用于编辑当前页面文本框值。
This is my content.js page 这是我的content.js页面
window.addEventListener ("load", myMain, false); function myMain (evt) { try { var inputs, index; inputs = document.getElementsByTagName('input'); for (index = 0; index < inputs.length; ++index) { // deal with inputs[index] element. if(inputs[index].type=='text') { inputs[index].value='SampleValue'; } } } catch(e) { } }
This works fine for normal HTML pages. 这适用于普通的HTML页面。
BUT 但
This does not work for Salesforce visual force pages. 这对Salesforce可视化强制页面不起作用。 I've used document.getElementById('SamplemainPage:mainForm:pageBlock1:pageBlockSection1:myId1').value='Sample Text';
我使用了document.getElementById('SamplemainPage:mainForm:pageBlock1:pageBlockSection1:myId1').value='Sample Text';
at the bottom of my visualforce page, Then it works and change the value of my text box. 在我的visualforce页面的底部,然后它工作并更改我的文本框的值。
But when i put same code snippet to content.js it does not work. 但是,当我将相同的代码片段放到content.js时,它不起作用。
How it is possible? 怎么可能? because it says think content.js as a part of current web page. 因为它认为content.js是当前网页的一部分。 So i believe it should work 所以我相信它应该有效
1.Please upload you js file into static resource and 1.请将js文件上传到静态资源中
[ https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources_reference.htm][1] [ https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources_reference.htm] [1 ]
inlcude script like this 像这样的inlcude脚本
<apex:includeScript value="{!$Resource.MyJavascriptFile}"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.