欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

用js实现的一个Flash滚动轮换显示图片代码生成器

程序员文章站 2023-12-05 20:32:34
复制代码 代码如下:
复制代码 代码如下:

<!--文件头模板-->
<script src=top.js></script>
<script language=javascript>
    writetop('flash滚动显示图片代码生成','2006-10-18');
</script>

<!--以下为内容-->
<script>
//运行代码
function runex(cod1)  {
     cod=document.getelementbyid(cod1)
      var code=cod.value;
      if (code!=""){
          var newwin=window.open('','','');  
          newwin.opener = null 
          newwin.document.write(code);  
          newwin.document.close();
    }
}
//复制代码
function docopy(id) { 
    if (document.all){
         textrange = document.getelementbyid(id).createtextrange(); 
         textrange.execcommand("copy"); 
    }
    else{
         alert("此功能只能在ie上有效")
    }
}

//展开_收起段落
function close_open(theid){
    if(document.getelementbyid(theid).style.display!='none') {
        document.getelementbyid(theid).style.display='none';
    }
    else 
        document.getelementbyid(theid).style.display='block';
}
</script>

<script language=javascript>
    //生成代码
    function gencode()
    {
        var html='';
        var picurl='';
        var piclink='';
        var pictitle='';
        var picwidth=0;
        var picheight=0;
        var titleheight=0;
        var backgroudn='';

        {
            var tempurl='';
            var templink='';
            var temptitle='';
            for(i=0;i<9;++i){
                tempurl=document.getelementbyid('picurl_'+(1+i)).value;
                templink=document.getelementbyid('piclink_'+(1+i)).value;
                temptitle=document.getelementbyid('pictitle_'+(1+i)).value;
                if(tempurl == '')continue;
                if(templink == '')templink=tempurl;
                if(temptitle == '')temptitle='无题';
                picurl   += tempurl + '|';
                piclink  += templink + '|';
                pictitle += temptitle + '|';
            }
            picurl = picurl.substring(0,picurl.length-1);
            pictitle = pictitle.substring(0,pictitle.length-1);
            piclink = piclink.substring(0,piclink.length-1);
            picwidth = parseint(document.getelementbyid('picwidth').value);
            picheight=parseint(document.getelementbyid('picheight').value);
            titleheight = parseint(document.getelementbyid('titleheight').value);
            backgroudn = document.getelementbyid('backgroudn').value;
        }

        html += '<embed pluginspage=http://www.macromedia.com/go/getflashplayer src=http://staryxy.googlepages.com/picplay.swf';
        html += ' width='  + picwidth;
        html += ' height=' + (picheight + titleheight);
        html += ' type=application/x-shockwave-flash wmode="opaque" flashvars="';
        html += 'pics='+picurl;
        html += '&links='+piclink;
        html += '&texts='+pictitle;
        html += '&borderwidth=' + picwidth;
        html += '&borderheight=' + picheight;
        html += '&textheight=' + titleheight;
        html += '" menu="false"';
        html += ' bgcolor="' + backgroudn;
        html += '" quality="high" allowscriptaccess="samedomain"></embed>';

        document.getelementbyid('showcode').value = html;
        show.innerhtml = html;
    }
</script>

<div style="margin-top:5px;background:#9abcde">
<div style='cursor:hand' onclick=close_open('edit')><li>设置</li></div>
<div id='edit' style="margin-left:15px; display:block;">
    <div style="background:#cdcdcd">
        图片显示宽度:<input size=10 id=picwidth   title="图片显示宽度" value="300"></input>
        图片显示高度:<input size=10 id=picheight  title="图片显示高度" value="200"></input>
        文字区域高度:<input size=10 id=titleheight title="文字区域高度" value="20"></input>
        背景色:<input size=10 id=backgroudn title="背景色" value='#cdcdcd'></input>
    </div>
    <div style="background:#eeeeee">
        图片一:
        <input maxlength=2048 size=25 id=picurl_1 value="http://staryxy.googlepages.com/diner1.jpg" title="图片url地址"></input>
        链接地址:<input maxlength=2048 size=25 id=piclink_1 value="" title="链接地址"></input>
        说明:<input maxlength=2048 size=20 id=pictitle_1 value="「夜宴」搞恶图片1" title="说明"></input>
    </div>
    <div style="background:#cdcdcd">
        图片二:
        <input maxlength=2048 size=25 id=picurl_2 value="http://staryxy.googlepages.com/diner2.jpg" title="图片url地址"></input>
        链接地址:<input maxlength=2048 size=25 id=piclink_2 value="" title="链接地址"></input>
        说明:<input maxlength=2048 size=20 id=pictitle_2 value="「夜宴」搞恶图片2" title="说明"></input>
    </div>
    <div style="background:#eeeeee">
        图片三:
        <input maxlength=2048 size=25 id=picurl_3 value="http://staryxy.googlepages.com/diner4.jpg" title="图片url地址"></input>
        链接地址:<input maxlength=2048 size=25 id=piclink_3 value="" title="链接地址"></input>
        说明:<input maxlength=2048 size=20 id=pictitle_3 value="「夜宴」搞恶图片3" title="说明"></input>
    </div>
    <div style="background:#cdcdcd">
        图片四:
        <input maxlength=2048 size=25 id=picurl_4 value="http://staryxy.googlepages.com/diner7.jpg" title="图片url地址"></input>
        链接地址:<input maxlength=2048 size=25 id=piclink_4 value="" title="链接地址"></input>
        说明:<input maxlength=2048 size=20 id=pictitle_4 value="「夜宴」搞恶图片4" title="说明"></input>
    </div>
    <div style="background:#eeeeee">
        图片五:
        <input maxlength=2048 size=25 id=picurl_5 value="http://staryxy.googlepages.com/diner8.jpg" title="图片url地址"></input>
        链接地址:<input maxlength=2048 size=25 id=piclink_5 value="" title="链接地址"></input>
        说明:<input maxlength=2048 size=20 id=pictitle_5 value="「夜宴」搞恶图片5" title="说明"></input>
    </div>
    <div style="background:#cdcdcd">
        图片六:
        <input maxlength=2048 size=25 id=picurl_6 value="http://staryxy.googlepages.com/diner12.jpg" title="图片url地址"></input>
        链接地址:<input maxlength=2048 size=25 id=piclink_6 value="" title="链接地址"></input>
        说明:<input maxlength=2048 size=20 id=pictitle_6 value="「夜宴」搞恶图片6" title="说明"></input>
    </div>
    <div style='cursor:hand' onclick=close_open('editmore')><li>更多(推荐6张以下,否则说明将看不到)</li></div>
    <div id='editmore' style='display:none;'>
        <div style="background:#eeeeee">
            图片七:
            <input maxlength=2048 size=25 id=picurl_7 value="" title="图片url地址"></input>
        链接地址:<input maxlength=2048 size=25 id=piclink_7 value="" title="链接地址"></input>
        说明:<input maxlength=2048 size=20 id=pictitle_7 value="" title="说明"></input>
        </div>
        <div style="background:#cdcdcd">
            图片八:
            <input maxlength=2048 size=25 id=picurl_8 value="" title="图片url地址"></input>
        链接地址:<input maxlength=2048 size=25 id=piclink_8 value="" title="链接地址"></input>
        说明:<input maxlength=2048 size=20 id=pictitle_8 value="" title="说明"></input>
        </div>
        <div style="background:#eeeeee">
            图片九:
            <input maxlength=2048 size=25 id=picurl_9 value="" title="图片url地址"></input>
        链接地址:<input maxlength=2048 size=25 id=piclink_9 value="" title="链接地址"></input>
        说明:<input maxlength=2048 size=20 id=pictitle_9 value="" title="说明"></input>
        </div>
    </div>
</div>
<div>
    <input type=button onclick='javascript:gencode();' value=生成代码>
    </input>
</div>
</div>


<div style="margin-top:5px;background:#9abcde">
<div onclick=close_open('code')  style='cursor:hand'><li>代码</li></div>
<div id='code' style='margin-left:15px;display:none;'>
<textarea rows="15" id="showcode" style="width:100%">
<!--此处显示结果代码-->
</textarea>
</div>
<div>
    <input onclick="runex('showcode')"  type="button" value="运行此代码"/>
    <input onclick="docopy('showcode')"  type="button" value="复制此代码"/>
    [ctrl+a 全部选择 提示:你可先修改部分代码,再按运行]
</div>
</div>



<div style="margin-top:5px;background:#9abcde;">
    <div onclick=close_open('show')  style='cursor:hand'><li>显示效果</li></div>
    <div id='show' title="显示效果" align=center style="margin-left:15px;display:none;background:#abcdef">
    还没有
    </div>
</div>
</div>