473,289 Members | 1,940 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,289 software developers and data experts.

solution to display text rotated 90 vertically in firefox css

I have been searching for hours to find a solution to display text rotated at 90 degrees in firefox, and could not find one. css3 and IE has the css command "writing-mode: tb-rl;" but this does not work in firefox. i came to conclusion that SVG is the solution. I have been playing with SVG for few hours now and it is brilliant, you can do graphics and animation like flash but text and javascript based!. anyway check this out, this is one solution to do it in svg and it works.

put this in html document

Expand|Select|Wrap|Line Numbers
  1. <embed class="svgex" src="../thefile.svg" type="image/svg+xml" frameborder="no" width="30" height="60" />
and here is the svg file

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
  3. <svg version="1.1"   xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  4. <script type="text/javascript">
  5. <![CDATA[
  6. //this will create htmljavascriptfunctionname in html document and link it to changeText
  7. top.htmljavascriptfunctionname = changeText;
  8.  
  9. function changeText(txt){
  10.    targetText=document.getElementById("thetext");
  11.    var newText = document.createTextNode(txt);
  12.    targetText.replaceChild(newText,targetText.childNodes[0]);
  13. }
  14. // ]]>
  15. </script>
  16. <text id="thetext" transform="rotate(90,4,4)" font-size="10" x="4" y="4" font-family="Verdana">this text is rotated </text> 
  17.  
  18. </svg>
This idea could be developed further to create the svg object in the html document dom, dynamically with javascript and therefore with no external svj file or an embed object being required. if this woudl be useful to you let me know
Oct 11 '07 #1
5 64162
drhowarddrfine
7,435 Expert 4TB
SVG is great and it should be used everywhere but it only works in modern browsers and not IE6/7.
Oct 11 '07 #2
It's been a couple years since this thread was started, so I hope I'm not too late. Please reply if you can.

I can get this to work--sort of. Following the instructions, I get the text line saying "This line is rotated" turned 90 degrees. Terrific. But the CDATA section in the svg document contains a javascript function with a parameter: txt, which to me suggests that I should be able to call that function from within the HTML document (in javascript, of course), include a different line of text as the argument, and have that new text rotated. But I can't get it to work. I can't call the function from the HTML document: I get an "Undefined variable" error. And since the .svg file is embedded, I can't figure out how to address it (ie, with something like embed.document.getElementById() or embed.changeText(new text). I've tried moving the changeText() function to the HTML document, but again, I can't then get the internal function statements to point to the .svg file.

I'm reasonably competent with HTML and javascript, but I've never worked with .svg before. I read up on it a bit, but the problem doesn't seem to be with .svg per se; it's with linking the .svg file to the HTML document.

This idea could be developed further to create the svg object in the html document dom, dynamically with javascript and therefore with no external svj file or an embed object being required. if this woudl be useful to you let me know
Maybe this is the answer. It sounds like it should be. Has anyone worked out how to do it?

FYI: I'm using Opera 9.64, not Firefox. But since I get the correct rotation of the original line, I can't imagine the problem is with the browser.
Aug 14 '09 #3
Hi,

At the beginning of the CDATA section, see this assignment:

top.htmljavascriptfunctionname = changeText;

This "binds" the function changeText (which is in the context of the SVG object), to a function (called htmljavascriptfunctionname which you need to call ) in the containing HTML document.

So in your HTML page, call the function htmljavascriptfunctionname() whenever you want to change the text. e.g.

htmljavascriptfunctionname("my next text");

This works on FF 3.5, I assume it will on Opera.

Hope this helps,
Asaf.
Aug 26 '09 #4
Thanks for the tip, AsafAmit. I'll give it a try.

I finally did figure out another way to do it. First move the changeText function to the HTML document. From within that HTML doc, open the .svg doc with javascript, assigning a variable to the window.open statement:

Expand|Select|Wrap|Line Numbers
  1. turnTextPage = window.open( "savedDocument.svg","","params, etc.");
Then add the variable name to the changeText function:

Expand|Select|Wrap|Line Numbers
  1. function changeText( lineID, text ){
  2.     targetText = turnTextPage.document.getElementById( lineID ) ;
  3.     var newText = turnTextPage.document.createTextNode( text ) ;
  4.     targetText.replaceChild( newText, targetText.childNodes[0] );
  5. }
SInce the function is now in the HTML doc, you can call it the normal way, and the text lines will be transferred to the .svg doc.
Aug 27 '09 #5
I tried to replace flash SWF object with sgv object. The followings are my code. The result is as the attached. It's not right.
I am more a server side person (JSF). Not 1 Javascript person Need some instruction to get this work. Thanks[IMG]file:///home/sling/dashboard.png[/IMG]
The image might not work. Basically, it display once out of place (in top of screen. All vertical line with undefined wording.
Expand|Select|Wrap|Line Numbers
  1. <t:dataList id="profileList" var="profile" value="#{Dashboard2Bean.profileList}" rowIndexVar="row">
  2.                     <td rowspan="2">                        
  3.                         <div id="verticalTextDiv">
  4.                          <script type="text/javascript">
  5.                              var output = '<h:outputText value="#{profile.vendorAbbrvName}" /> - <h:outputText value="#{profile.name}" />';
  6.                              document.writeln(displayVerticalText(output));
  7.                         </script>
  8.                         </div>
  9.                     </td>
  10.                 </t:dataList>
  11.  
Nov 11 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: bob | last post by:
Does anyone know if it is possible to display text vertically in HTML? Basically, I want normal text rotated 90 degrees.
8
by: Harry Haller | last post by:
The right arrow in IE is displayed aligned to the bottom of the line. Is there any way I can display it aligned vertially in the middle? Example: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01...
6
by: charsh | last post by:
Hi, I using the code below to draw a text in a pictureBox1. //Start--------------------------------------------------------------- private void button1_Click(object sender, System.EventArgs e)...
3
by: James Radke | last post by:
Hello, How can I make the text of a windows textbox read vertically (i.e. rotated 90 degrees) from bottom to top instead of horizontally? Any samples or ideas would be appreciated! Thanks!...
5
by: Ken Hunt | last post by:
I know how to draw text vertically. My problem is the StringFormatFlags.DirectionVertical command rotates the text 90 degrees clockwise. I want it rotated 90 degrees counter-clockwise (I'm making a...
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
2
by: Tilo Pätzold | last post by:
Hi Everybody (especially Microsoft), we build EMF files with rotated text for export to office (powerpoint, word). It is planned that the text can be edited in the office document. Without the...
0
by: pamelafluente | last post by:
Hello experts, I need some help to do in a proper way what I am doing. I have some "cells" in a web page. Each "cell" is made of 2 DIV. One is inside the other. Example with 2 "cells" : <div...
22
Atli
by: Atli | last post by:
Hi. I'm setting up a small photo-album-type thing, where I use PHP to set up a list of images for visitors to click through. That's all simple enough. However, I'm having a weird bug in IE8. ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.