How to create embed code for other sites

后端 未结 2 1741
情歌与酒
情歌与酒 2020-12-12 17:43

I have a service of job portal which other users can use for their sites and blogs. they copy embed code from my site, paste it in their site and display job board in their

相关标签:
2条回答
  • 2020-12-12 18:02

    there are many ways to reach your goal. As you didn't explain your need explicitly, I just provide a simple example:

    <script type='text/javascript' charset='utf-8'>     
       var iframe = document.createElement('iframe');       
       document.body.appendChild(iframe);
    
       iframe.src = 'URL OF CONTENT YOU WANT TO PROVIDE';       
       iframe.width = 'THE WIDTH YOU WANT';
       iframe.height = 'THE HEIGHT YOU WANT';
    </script>
    
    1. modify the code according to your need
    2. escape this code in your html
    3. have fun with your awesome embedded widget!
    0 讨论(0)
  • 2020-12-12 18:06

    How To Create Embed With Javascript in .cs

    Note: localhost:3197/website/js/embed/form.js'; // give your js path

    FormBuilder(921,'MjEzNjkxMjU='); in this method first parameter give your form height and second your form name or Id. there Id is encoded format

    StringBuilder sb = new StringBuilder();
        sb.Append("<script type='text/javascript'>");
        sb.Append("(function(d, t) { var s = d.createElement(t), options = {");
        sb.Append("'async':true };");
        sb.Append("s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'localhost:3197/website/js/embed/form.js';");
        sb.Append("s.onload = s.onreadystatechange = function() {");
        sb.Append("var rs = this.readyState; if (rs) if (rs != 'complete') if (rs != 'loaded') return;");
        sb.Append("try { frm = new FormBuilder("+Form Height+",'"+FormId+"');frm.initialize(options);frm.display(); }");
        sb.Append("catch (e) {}};");
        sb.Append("var scr = d.getElementsByTagName(t)[0], par = scr.parentNode; par.insertBefore(s, scr);");
        sb.Append("})(document, 'script');</script>");
    
        txtjavascript.Value = sb.ToString();  // text box name
    

    After Create embed script Simple and Easy Way Paste this script where you want to show in other page after that

    (function(d, t) { var s = d.createElement(t), options = {'async':true }; s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'localhost:3197/website/js/embed/form.js'; s.onload = s.onreadystatechange = function() {var rs = this.readyState; if (rs) if (rs != 'complete') if (rs != 'loaded') return; try { frm = new FormBuilder(921,'MjEzNjkxMjU='); frm.initialize(options); frm.display(); }catch (e) {}}; var scr = d.getElementsByTagName(t)[0], par = scr.parentNode; par.insertBefore(s, scr);})(document, 'script');

    After That in your js file Create fuction like this and create iFrame ans create querystring where you fetch the form from database.

    function FormBuilder(fHeight, formid) {
    
        var iframe = document.createElement('iframe');
        iframe.style = "height:" + fHeight + "px; width:100%; border:none";
        iframe.setAttribute('allowTransparency', true);
        iframe.frameBorder = "0";
        iframe.scrolling = "no";
        iframe.src = "http://localhost:3197/form/show-form?id="+ formid;
        document.body.appendChild(iframe);
    }
    
    0 讨论(0)
提交回复
热议问题