473,396 Members | 2,039 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.

"window.open" from selection WITH formatting

Currently I'm trying to make a plugin for my browser (Maxthon/IE6)
which allows me to select any text on the current page and press the
plugin button to create a new tab with the selection.

This will do the job:
<script language="JavaScript">
javascript:r4NSy3m=document.selection.createRange( );oDgs2Ke=r4NSy3m.text;dT30FfN=new
Date();wdGs8c6=window.open('','w'+dT30FfN.getTime( ),'');wdGs8c6.document.write(oDgs2Ke);
void(wdGs8c6.document.close())
</script>

Unfortunately, I want to retain the layout of the text and the above
code strips it out.
The code on http://www.webreference.com/js/colum...ssbrowser.html
seems to do precisely what I want but it displays the current selection
in a box on the page. I'm not interested in using 'onmouseup' as I want
to decide when the page should open.

Can someone please show me how to make the webreference example work in
a new page on demand.

Jul 23 '05 #1
2 1515


me*****@gmail.com wrote:
Currently I'm trying to make a plugin for my browser (Maxthon/IE6)
which allows me to select any text on the current page and press the
plugin button to create a new tab with the selection.

This will do the job:
<script language="JavaScript">
javascript:r4NSy3m=document.selection.createRange( );oDgs2Ke=r4NSy3m.text;dT30FfN=new
Date();wdGs8c6=window.open('','w'+dT30FfN.getTime( ),'');wdGs8c6.document.write(oDgs2Ke);
void(wdGs8c6.document.close())
</script>

Unfortunately, I want to retain the layout of the text and the above
code strips it out.


var range = document.selection.createRange();
var html = range.htmlText;
var win = window.open('', 'w' + new Date().getTime());
win.document.open();
win.document.write(html);
win.document.close();
void 0

is probably what you are after, put on one line in a javascript:
bookmark of course.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Beautiful - thank you so much.

Jul 23 '05 #3

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

Similar topics

3
by: Shiperton Henethe | last post by:
Hi Can anyone tell me how to open up a new normal, full-sized browser window from a small popup window? I'm using something like this. <script language="javascript"> <!--
5
by: Brandon Potter | last post by:
Forgive me if this has already been covered... I use dual displays and have 2 - 3 Visual Studio .NET 2003's open at the same time, however, without fail, at some point during my session, the...
3
by: JohnEGee | last post by:
Hello, all, and TIA for any help you can offer. I've searched the Internet for answers and have finally come here. I've created a page (several, actually) with a link that opens a pop-up...
5
by: lindanr | last post by:
In ASP.NET 2005 I have an onblur="window.close()" javascript event in the <body> tag. When I click on the window's scrollbar, the window closes. The same code works fine in ASP.NET 2003. Any...
1
by: kbarrios | last post by:
Hi, I am working with VBScript and I put a "window.open" inside a "form action post" due that I am handing a "checkbox" on it, but the "window.open" doesn't work: <FORM...
1
by: R Reyes | last post by:
Hi, For some reason, the website I made does not open pages in a new page whenever I right-click "Open in New Tab" or "Open in New Window". But, as soon as I navigate to any other website, the...
4
by: arajunk | last post by:
In Firefox this opens a full size window (maximized) . In IE it opens the partial window requiring user to click restore (upper right) to maximize. What am I missing ? var...
4
by: jodleren | last post by:
Hi all I have a file I open in a smaller window, like this: <a href="#" onclick="window.open.... but it also causes the main window to jump to the top. What have people done to avoid that?...
1
gcoaster
by: gcoaster | last post by:
Hello, Access is accessing my patience! how does one filter just one form with a single combo box selection? I have a combo box named "cboCallStatus" unbound Row source type = Value...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.