Showing posts with label Java Script. Show all posts
Showing posts with label Java Script. Show all posts

Friday, October 28, 2022

Copy to Clipboard using Javascript

 Copying the text to clipboard makes it easier to use the web page, so users will definitely like this functionality. You can achieve it using JavaScript.

Note: For this function to work in production environment, make sure your website has SSL Certificate

Sample:

  <asp:Button ID="btnCopyResult" Visible ="false"   OnClientClick="CopyToClipBoard();"   class="btn btn-primary btn-sm"   runat="server" Text="Copy Result" />  

 <script type="text/javascript">

  function CopyToClipBoard()

 {

var sData = "Copy ME!";

try 

{

      navigator.clipboard.writeText(sData);

     return true;

 }

 catch (err) 

{

    alert('Could not write to clipboard', err);

    return false;

}

}

Thursday, February 9, 2012

Open PopUp window using JScript in ASP.NET

Open PopUp window using JScript in ASP.NET <p>
<a href="javascript:open_popup('OrganizationDetails.aspx')">OrganizationName</a
>

</p>
 
 <script language="JavaScript"> 
 function open_popup(page)  
 {  
 window_handle = window.open(page,'popupWindowName');  
 window_handle.focus();  
 } 
 </script> 
 //The variable window_handle is used to retain the reference to the pop-up window throughout the life of the current document. 
  As soon as the pop-up window is created, or its contents are requested to be changed, then the focus 
 () method ensures that it is brought to the top of the stack of visible windows. 

Tuesday, August 30, 2011

How to open new window (popup) and center on screen

Here is a JavaScript function that open a new window and put in on the center of screen

<script type="text/javascript">

function poponload() {

var left = (screen.width / 2) - (990 / 2);

var top = (screen.height / 2) - (560 / 2);

testwindow = window.open('MyTestPopUp.aspx', 'PopUp', 'location=1,status=1,scrollbars=1,resizable=0,width=990, height=560, top='+top+', left='+left);

       

}

</script>

Monday, July 11, 2011

Redirects the parent page to a loacation

The following C# code defines the JavaScript code for redirecting parent page to new location, and registers it to execute immediately upon the page being posted back the next time.

// Redirects the parent page to a loacation.
public void RedirectParentPage(string sUrl)
{
string str = string.Format("window.parent.location='{0}';", sUrl);

ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), str, true);

}

How to upload app to macOS

1. Open Terminal Press Cmd (⌘) + Space , type Terminal , and hit Enter . 2. Navigate to Your Build Output Directory Your .app file is likel...