import torrus 1.0.9
[freeside.git] / fs_selfservice / FS-SelfService / cgi / iframecontentmws.js
1 /*\r
2  iframecontentmws.js - Foteos Macrides (author and copyright holder)\r
3    Initial: October 10, 2004 - Last Revised: January 26, 2008\r
4  Scripts for using HTML documents as iframe content in overlibmws popups.\r
5 \r
6  See http://www.macridesweb.com/oltest/IFRAME.html\r
7  and http://www.macridesweb.com/oltest/AJAX.html#ajaxex3\r
8  for more information.\r
9 */\r
10 \r
11 /*\r
12  Use as lead argument in overlib or overlb2 calls.  Include WRAP and\r
13  TEXTPADDING,0 in the call to ensure that the width arg is respected (unless\r
14  the CAPTION plus CLOSETEXT widths add up to more than the width arg, in which\r
15  case you should increase the width arg).  The name arg should be a unique\r
16  string for each popup with iframe content in the document.  The frameborder\r
17  arg should be 1 (browser default if omitted) or 0.  The scrolling arg should\r
18  be 'auto' (default if omitted), 'yes' or 'no'.\r
19 */\r
20 function OLiframeContent(src, width, height, name, frameborder, scrolling) {\r
21  \r
22  /* stupid safari iframe location caching... */\r
23  var d = new Date();\r
24  var unique = d.getTime() + '' + Math.floor(1000 * Math.random());\r
25  name = name + '' + unique;\r
26 \r
27  return ('<iframe src="'+src+'" width="'+width+'" height="'+height+'"'\r
28  +(name!=null?' name="'+name+'" id="'+name+'"':'')\r
29  +(frameborder!=null?' frameborder="'+frameborder+'"':'')\r
30  +' scrolling="'+(scrolling!=null?scrolling:'auto')\r
31  +'"><div>[iframe not supported]</div></iframe>');\r
32 }\r
33 \r
34 /*\r
35  Swap the src if we are iframe content.  The name arg should be the same\r
36  string as in the OLiframeContent function for the popup.  The src arg is\r
37  a partial, relative, or complete URL for the document to be swapped in.\r
38 */\r
39 function OLswapIframeSrc(name, src){\r
40  if(parent==self){\r
41   alert(src+'\n\n is only for iframe content');\r
42   return;\r
43  }\r
44  var o=parent.OLgetRef(name);\r
45  if(o)o.src=src;\r
46  else alert(src+'\n\n is not available');\r
47 }\r
48 \r
49 /*\r
50  Emulate the Back button if we are iframe content.  Use only in documents\r
51  which are swapped in by using the OLswapIframeSrc function.\r
52 */\r
53 function OLiframeBack(){\r
54  if(parent==self){\r
55   alert('This feature is only for iframe content');\r
56   return;\r
57  }\r
58  history.back();\r
59 }\r