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


C# WebBrowser.InvokeScript方法代码示例

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


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

示例1: clearOverlays

		//OK-I GUESS
		/**
		 * This method is used (or rather CAN be used) for clearing the overlays (markers) on the map
		 * @param target
		 */
		public static void clearOverlays(WebBrowser target)
		{
			if (target == null)
				return;

            //target.InvokeScript("UI_ClearOverlays");
			target.InvokeScript("eval", "clearOverlays()");
			//target.loadUrl("javascript:UI_ClearOverlays()");
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:14,代码来源:JSInterface.cs

示例2: Exec

 /// <summary>
 ///  在browser中执行js脚本
 /// </summary>
 /// <param name="browser">WebBrowser</param>
 /// <param name="scriptName">待执行的脚本方法名称</param>
 /// <param name="args">传给脚本的参数</param>
 /// <returns>js方法是否调用成功</returns>
 public bool Exec(WebBrowser browser, string scriptName, string[] args)
 {
     try
     {
         browser.InvokeScript(scriptName, args);
         return true;
     }
     catch (Exception ex)
     {
         // 由于InvokeScript确实可能抛出一些未知异常,必须捕获
         XLog.WriteError("Exception while calling js function: " + scriptName);
         XLog.WriteError("Exception Message: " + ex.Message);
         return false;
     }
 }
开发者ID:polyvi,项目名称:xface-wp8,代码行数:22,代码来源:XSafeBrowserScriptInvoker.cs

示例3: centerAt

		//OK-I GUESS
		public static void centerAt(WebBrowser target, double lat, double lon)
		{
			if (target == null)
				return;
            //string[] args = new string[] { lat.ToString(), lon.ToString() };
            //target.InvokeScript("centerAt", args);

            try
            {
                target.InvokeScript("eval", "centerAt(" + lat + ", " + lon + ")");
            }
            catch (SystemException ex)
            {
                System.Windows.MessageBox.Show(string.Format("{0} \n {1}", ex.Message, ex.StackTrace));
            }
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:17,代码来源:JSInterface.cs

示例4: logout

        private void logout()
        {
            var logoutUri = new Uri("http://note.youdao.com/?auto=1");
            var wb = new WebBrowser {IsScriptEnabled = true};
            wb.LoadCompleted += (sender, e) =>
            {
                try
                {
                    wb.InvokeScript("eval", "document.getElementById('dropdown-list').style.display = 'block';var links = document.getElementsByTagName('a');for (var i = 0; i < links.length; i++) { if (links[i].innerText == '注销') { links[i].click(); break; } }");
                }
                catch (Exception ex)
                {
                    LoggerFactory.GetLogger().Error("退出有道云笔记登录时失败", ex);
                }
                finally
                {
                    NavigationService.Navigate(new Uri("/Views/MainView.xaml?from=authorizePage", UriKind.Relative));
                }
            };

            wb.Navigate(logoutUri);
        }
开发者ID:ciker,项目名称:WPYoudaonNote,代码行数:22,代码来源:AuthorizeView.xaml.cs

示例5: updateSelectedLocation

		//OK
		//Moves the current select location by the specified number of pixels
		public static void updateSelectedLocation(WebBrowser target, int xPixels, int yPixels)
		{
			if (target == null)
				return;

			try
			{
				target.InvokeScript("eval", "updateSelectedLocation(" + xPixels + ", " + yPixels + ")");
			}
			catch (Exception ex)
			{
				System.Windows.MessageBox.Show(ex.Message);
			}
			//target.loadUrl("javascript:updateSelectedLocation(" + xPixels + ", " + yPixels + ")");
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:17,代码来源:JSInterface.cs

示例6: updateNewLocation

		//OK
		//Show the estimated location and a circle around it denoting the positioning accuracy
		public static void updateNewLocation(WebBrowser browser, SmartCampusWebMap.WifiSnifferPositioningService.PositionEstimate location)
		{
			//Create json location and send it to javascript
			StringBuilder jsonLoc = new StringBuilder();

            jsonLoc.Append("{");
            //jsonLoc.Append("hasAltitude: ").Append(location.ha.hasAltitude()).Append(", ");
            jsonLoc.Append("hasAccuracy: ").Append(location.HasAccuracy).Append(", ");
            jsonLoc.Append("hasBearing: ").Append(location.HasBearing).Append(", ");
            jsonLoc.Append("hasSpeed: ").Append(location.HasSpeed).Append(", ");
            jsonLoc.Append("accuracy: ").Append(location.Accuracy).Append(", ");
            jsonLoc.Append("bearing: ").Append(location.Bearing).Append(", ");
            jsonLoc.Append("speed: ").Append(location.Speed).Append(", ");
            jsonLoc.Append("latitude: ").Append(location.Latitude).Append(", ");
            jsonLoc.Append("longitude: ").Append(location.Longitude).Append(", ");
            jsonLoc.Append("altitude: ").Append(location.Altitude); //The last - no comma
            //jsonLoc.Append("time: ").Append(location.Time);
            jsonLoc.Append("}");

			browser.InvokeScript("eval", "updateNewLocation(" + jsonLoc.ToString() + ")"); //DOES work (but still exception)
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:23,代码来源:JSInterface.cs

示例7: showVertices

		public static void showVertices(WebBrowser browser, IEnumerable<Vertex> vertices, int floorNum, bool isOnline)
		{
			String result;
			if (vertices == null)
				result = "[]"; //this is the default json if no vertices are available
			else
			{
				StringBuilder foliaLocations = new StringBuilder();
				foliaLocations.Append("[");
				bool firstElem = true;
				foreach (Vertex v in vertices)
				{
					if (!firstElem)
						foliaLocations.Append(", ");
					firstElem = false;

					foliaLocations.Append(createFoliaJsonLocationJava(v));
				}
				foliaLocations.Append("]");
				result = foliaLocations.ToString();

			}
			//Til debugging:
			//result = "[{id: 621, latitude: 57.012376850985, longitude: 9.9910009502316, altitude: 0.0, title: 'Aalborg University', description: 'Tag en tur', url: 'no', location_type: 8, isStairEndpoint: false, isElevatorEndpoint: false, isEntrance: false}]";
			
			try
			{
				browser.InvokeScript("eval", "addGraphOverlay(" + floorNum + "," + isOnline.ToString().ToLower() + "," + result + ")");
			}
			catch (Exception ex)
			{
				System.Windows.MessageBox.Show(ex.Message);
			}
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:34,代码来源:JSInterface.cs

示例8: showSelectedLocation

		//OK
		//Show selected location (for new signal strength measurement) (with sniper icon)
		public static void showSelectedLocation(WebBrowser target, double lat, double lon)
		{
			if (target == null)
				return;

			target.InvokeScript("eval", "showSelectedLocation(" + lat + ", " + lon + ")");
			//target.loadUrl("javascript:showSelectedLocation(" + lat + ", " + lon + ")");
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:10,代码来源:JSInterface.cs

示例9: showEdges

		//OK
		/**
		* HACK: Building is not necessary; floor number is hardcoded 
		* This method sends the edges that needs to be shown on a map.
		* NOTE: The floorNum and isOnline parameters may very well be redundant
        * To use curEdge.Vertices update all existing links and change Android/iPhone so an actual link is added.  
		*/
        public static void showEdges(WebBrowser target, IEnumerable<Edge> edges, int floorNum)
		{
			if (target == null)
				return;
            
			String result;
			if (edges == null)
				result = "[]"; //this is the default json if no edges are available
			else
			{
				StringBuilder foliaEdges = new StringBuilder();
				foliaEdges.Append("[");
				bool firstElem = true;
				foreach (Edge e in edges)
				{
					if (!firstElem)
						foliaEdges.Append(", ");
					firstElem = false;
					
                    foliaEdges.Append(JSInterface.createFoliaJsonEdge(e));
				}
				foliaEdges.Append("]");
				result = foliaEdges.ToString();

			}
			try
			{
				//Load the edges
				target.InvokeScript("eval", "showEdges(" + floorNum + ", " + result + ")");
				//target.loadUrl("javascript:showEdges(" + floorNum + ", " + result + ")");
			}
			catch (Exception ex)
			{
				string msg = ex.Message;
				msg = ex.InnerException != null ? msg + ex.InnerException.Message : msg;
				System.Windows.MessageBox.Show(msg);
			}
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:45,代码来源:JSInterface.cs

示例10: setProviderStatus

		//NOT TESTED - bruges vist ikke pt. 
		/**
		 * Tells what the current provider is. If the provider is none - we can remove the estimate-circle.
		 * @param target
		 * @param Status
		 */
		public static void setProviderStatus(WebBrowser target, int status)
		{
			if (target == null)
				return;

			target.InvokeScript("eval", "setProviderStatus('" + status + "')");
			//target.loadUrl("javascript:setProviderStatus('" + Status + "')");
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:14,代码来源:JSInterface.cs

示例11: setIsTracking

		//NOT TESTED - har ingen knap
		/**
		 * Tells whether we are tracking the user's current position, i.curEdge., if we want the map to center around it. 
		 * @param target
		 * @param doTrack
		 */
		public static void setIsTracking(WebBrowser target, bool doTrack)
		{
			if (target == null)
				return;

			target.InvokeScript("eval", "setIsTracking(\"" + doTrack.ToString() + "\")");
			//target.loadUrl("javascript:setIsTracking(\"" + stringTrack + "\")");
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:14,代码来源:JSInterface.cs

示例12: setEndpoint

		//NOT TESTED - afhængig af UI_ShowVertices
		/**
		 * This method is called when a user selects an endpoint in the add/remove webview
		 * @param vertexId
		 */
		public static void setEndpoint(WebBrowser target, int vertexId)
		{
			if (target == null)
				return;

			target.InvokeScript("eval", "setEndpoint(" + vertexId + ")");
			//target.loadUrl("javascript:setEndpoint(" + vertexId + ")");
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:13,代码来源:JSInterface.cs

示例13: search

		//NOT TESTED
		public static void search(WebBrowser target, String query)
		{
			if (target == null)
				return;

			target.InvokeScript("eval", "search('" + query + "')");
			//target.loadUrl("javascript:search('" + query + "')");
		}
开发者ID:jiangxianliang,项目名称:SmartCampusAAU,代码行数:9,代码来源:JSInterface.cs

示例14: eventHandler

        private void eventHandler(Object sender, EventArgs e, String eventName, String handle, WebBrowser browser)
        {
            TiResponse response = new TiResponse();
            response["_hnd"] = handle;
            response["type"] = eventName;

            if ((uint)instanceCount + 1 > UInt32.MaxValue) {
                throw new Exception("Reflection Handler Exception: Maximum instance count exceeded");
            }

            string senderHandle = instanceCount++.ToString();
            instances[senderHandle] = sender;
            response["sender"] = senderHandle;

            string eventArgsHandle = instanceCount++.ToString();
            instances[eventArgsHandle] = e;
            response["eventArgs"] = eventArgsHandle;

            browser.InvokeScript("execScript", new string[] { "tiwp8.fireEvent(" + JsonConvert.SerializeObject(response, Formatting.None) + ")" });

            instances.Remove(senderHandle);
            instances.Remove(eventArgsHandle);
        }
开发者ID:88to,项目名称:titanium_mobile,代码行数:23,代码来源:ReflectionRequestHandler.cs


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