473,396 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do MSDN web pages access the clipboard?

I am using the window.clipboardData.getData javascript method to copy
from the clipboard.

<SCRIPT LANGUAGE="JavaScript">
function ShowClipBoard()
{
var data = window.clipboardData.getData("text") ;
alert( data ) ;
}

</SCRIPT>

This works, but I am not prompted by the browser first, asking if I
want to allow access to the clipboard.

When I click "copy code" from an MSDN web page I first am prompted by
a browser message box asking if I want to allow access to the
clipboard.
http://msdn2.microsoft.com/en-us/library/ms533044.aspx

What method would the MSDN page be using to access the clipboard that
would cause the "allow access" prompt?

Is it just that I am running my test page from localhost? I want to
make sure I am using the most standards compliant method to copy to
and from the clipboard.

thanks,

-Steve

Jun 30 '07 #1
5 2748
"Steve Richter" <St************@gmail.comwrote in message
news:11********************@n60g2000hse.googlegrou ps.com...
What method would the MSDN page be using to access the clipboard that
would cause the "allow access" prompt?
I don't actually know the answer, so what follows is just theory...

Firstly, the CopyCode function doesn't appear in the page's View Source, so
I'm guessing it's in some JavaScript include file...Therefore, it's
impossible to tell what it's doing without some serious hacking...

Secondly, this appears to be an IE-only thing - the "Copy Code" hyperlinks
don't appear at all when the page is viewed in any other browser, even the
very latest version of FireFox (2.0.0.4)...

Thirdly, I'm not actually certain that it's doing anything cleverer than
popping a showModalDialog and storing the return value in a JavaScript
variable... Simple enough to do but, of course, showModalDialog is not
cross-browser compatible and most certainly not standards-compliant...
Curiously enough, the "Copy Code" hyperlinks don't appear on Safari either,
even though showModalDialog *is* supported on that browser - draw your own
conclusions there... ;-)
I want to make sure I am using the most standards compliant method
In which case, you need to change your <scripttag to:

<script type="text/javascript">
....
....
</script>

as the language tag is deprecated in XHTML...

Upper-case tag properties aren't supported either...
--
http://www.markrae.net

Jun 30 '07 #2
On Jun 30, 5:49 pm, Steve Richter <StephenRich...@gmail.comwrote:
Is it just that I am running my test page from localhost?
yes, it asked you on the MSDN site because of IE settings

Tools - Internet Options - Security - Internet - Custom level

Scroll down to "Scripting", "Allow Programmatic clipboard access"

Jun 30 '07 #3
On Jun 30, 12:41 pm, "Mark Rae" <m...@markNOSPAMrae.netwrote:
"Steve Richter" <StephenRich...@gmail.comwrote in message

news:11********************@n60g2000hse.googlegrou ps.com...
What method would the MSDN page be using to access the clipboard that
would cause the "allow access" prompt?

I don't actually know the answer, so what follows is just theory...

Firstly, the CopyCode function doesn't appear in the page's View Source, so
I'm guessing it's in some JavaScript include file...Therefore, it's
impossible to tell what it's doing without some serious hacking...

Secondly, this appears to be an IE-only thing - the "Copy Code" hyperlinks
don't appear at all when the page is viewed in any other browser, even the
very latest version of FireFox (2.0.0.4)...

Thirdly, I'm not actually certain that it's doing anything cleverer than
popping a showModalDialog and storing the return value in a JavaScript
variable... Simple enough to do but, of course, showModalDialog is not
cross-browser compatible and most certainly not standards-compliant...
Curiously enough, the "Copy Code" hyperlinks don't appear on Safari either,
even though showModalDialog *is* supported on that browser - draw your own
conclusions there... ;-)
I want to make sure I am using the most standards compliant method

In which case, you need to change your <scripttag to:

<script type="text/javascript">
...
...
</script>

as the language tag is deprecated in XHTML...

Upper-case tag properties aren't supported either...

--http://www.markrae.net
thanks. onward, to the next challenge ...



Jun 30 '07 #4
What you can do is this:

function ShowClipBoard()
{
if ( confirm("Do you want to copy this to the clipboard?"))
{
var data = window.clipboardData.getData("text") ;
alert( data ) ;
}
}

Cheers!
Ray
"Steve Richter" <St************@gmail.comwrote in message
news:11********************@n60g2000hse.googlegrou ps.com...
>I am using the window.clipboardData.getData javascript method to copy
from the clipboard.

<SCRIPT LANGUAGE="JavaScript">
function ShowClipBoard()
{
var data = window.clipboardData.getData("text") ;
alert( data ) ;
}

</SCRIPT>

This works, but I am not prompted by the browser first, asking if I
want to allow access to the clipboard.

When I click "copy code" from an MSDN web page I first am prompted by
a browser message box asking if I want to allow access to the
clipboard.
http://msdn2.microsoft.com/en-us/library/ms533044.aspx

What method would the MSDN page be using to access the clipboard that
would cause the "allow access" prompt?

Is it just that I am running my test page from localhost? I want to
make sure I am using the most standards compliant method to copy to
and from the clipboard.

thanks,

-Steve
Jun 30 '07 #5
I positive it's because localhost is the different zone (Local intranet)
than microsoft.com which's in Internet.
And different zones have different security settings

so as soon you move your code to domain.com you will be prompted as well

George.
"Steve Richter" <St************@gmail.comwrote in message
news:11********************@n60g2000hse.googlegrou ps.com...
>I am using the window.clipboardData.getData javascript method to copy
from the clipboard.

<SCRIPT LANGUAGE="JavaScript">
function ShowClipBoard()
{
var data = window.clipboardData.getData("text") ;
alert( data ) ;
}

</SCRIPT>

This works, but I am not prompted by the browser first, asking if I
want to allow access to the clipboard.

When I click "copy code" from an MSDN web page I first am prompted by
a browser message box asking if I want to allow access to the
clipboard.
http://msdn2.microsoft.com/en-us/library/ms533044.aspx

What method would the MSDN page be using to access the clipboard that
would cause the "allow access" prompt?

Is it just that I am running my test page from localhost? I want to
make sure I am using the most standards compliant method to copy to
and from the clipboard.

thanks,

-Steve

Jul 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dave | last post by:
Can i use A97 to act like a browser? I want to allow users to access certain internet sites without having to change from my Access DB to internet explorer thanks Dave
3
by: danit58 | last post by:
Anyone use il software ESRI ArcView GIS????? In a DB Access I store information about plot of land, house and related ownership. By click a button in a specific record, I want to open ESRI...
3
by: info | last post by:
After using clipboard functions in Excel controlled from Access VBA, Excel doesn't quit when I use the following ExcelApp.Quit Set ExcelApp = Nothing If I don't use the clipboard functions in...
11
by: Danny J. Lesandrini | last post by:
Has anyone else noticed this? I searched group archives and found nothing, but it's really starting to irritate me big time. Here's the steps to reproduce the problem: Copy something to the...
5
by: MLH | last post by:
I had a form (Form12) with a code error in it. I knew it was there. I even planned on fixing it (someday). I needed a comprehensive test of all my code so I clicked Debug, Compile All Modules. My...
8
by: pirho | last post by:
Not sure if I'm posting this in the right spot, but.... Lets say i have a class for data access that gets instantiated on each page in a web application ( .Net 1.1 ) From inside that class,...
4
by: =?Utf-8?B?ZG1idXNv?= | last post by:
I have an Access database with a table named 'tblMedia'. In tblMedia I have a field named 'Media' that is defined as an 'OLE Ojbect' field. In this Media field, I have pictures, they are jpegs. I'm...
8
by: marjbell | last post by:
I have a Access database of email addresses that I would like to mass email to customers. Can Access be used through Outlook? or can it just be done with Access? I know it is possible to use...
4
by: OldBirdman | last post by:
I'm working within the Access window because my program isn't quite completed. Some of my forms almost fill this space, which is as large as my monitor will support. If the Office Clipboard tries...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.