Getting Content from iFrames


I am trying to get to get the Content of an iFrame to a struct.
At the moment I only managed to get the content of an
<input name="title" id="title" type="text" size="80" maxlength="80" />
(at the end it should be simular like an cms system which I want to use for some XSS testing)

My Code at the moment:
HTML page:
Basicly just a simple text editor (I left the js out in the post since its not the issue)


   <body onLoad="iFrameOn();">
    <h2>Einfacher Text Editor .1v</h2>
    <form action="/save/{{.Title}}"  method="POST">
        <p>Entry Title: <input name="title" id="title" type="text"  size="80" maxlength="80" /></p>
        <p>Entry Body:<br>
        <div id="cms_cp" style="padding:8px; width:700px;">
            <input type="button" class="ButtonStyle" onClick="iBold()" value="B">
            <input type="button" class="ButtonStyle" onClick="iUnderline()" value="U">
            <input type="button" class="ButtonStyle" onClick="iItalic()" value="I">
            <select class="ButtonStyle" id="FontSize" onChange="iFontSize()">
                                <!--Hier die Schrift möglichen Schriftgrößen -->
                                    <option selected="selected">Font Size</option>
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                    <option value="6">6</option>
                                    <option value="7">7</option>
            <input   class="ButtonStyle" type="color" id="ColorHTML" onChange="iColorHTML()">
            <select class="ButtonStyle" id="FontName" onChange="iFontName()">
                <option selected="selected">Font</option>
                    <!-- Schriftarten Father -->
                    <optgroup label="Sans-Seriff">
                                    <!-- Schriftarten Son -->
                                    <option value="Helvetica">Helvetica</option>
                                    <option value="Verdana">Verdana</option>
                                    <option value="Lucida Grande">Lucida Grande</option>
                                    <option value="Arial">Arial</option>
                                    <option value="Calibri">Calibri</option>
                                    <option value="Comic Sans MS">Comic Sans MS</option>
                    <optgroup label="Seriff">
                                    <option value="Georgia">Georgia</option>
                                    <option value="Palatino">Palatino</option>
                    <optgroup label="Monospace">
                                    <option value="Courier New">Courier New</option>

        <input type="button" class="ButtonStyle"     onClick="iCenter()"         title="Center Text"     value="Center">
        <input type="button" class="ButtonStyle"     onClick="iLeft()"           title="Left Text"       value="Left">
        <input type="button" class="ButtonStyle"     onClick="iRight()"          title="Right Text"      value="Right">
        <input type="button" class="ButtonStyle"     onClick="iJustify()"        title="Justify Text"    value="Justifiy">
        <input type="button" class="ButtonStyle"     onClick="iIndent()"         title="Indent Text"     value="Indent">
        <input type="button" class="ButtonStyle"     onClick="iOutdent()"        title="Outdent Text"    value="Outdent">
        <input type="button" class="ButtonStyle"     onClick="iParagraph()"      title="New Paragraph"   value="New Paragraph">
        <input type="button" class="ButtonStyle"     onClick="iHorizontalRule()" title="Horizontal Rule" value="Horizontal">
        <input type="button" class="ButtonStyle"     onClick="iUnorderedList()"  title="Unordered List"  value="List Unordered">
        <input type="button" class="ButtonStyle"     onClick="iOrderedList()"    title="Ordered List"    value="List Ordered">
        <input type="button" class="ButtonStyle"     onClick="iLink()"           title="Link"            value="Link">
        <input type="button" class="ButtonStyle"     onClick="iUnLink()"         title="Unlink"          value="Unlink">
        <input type="button" class="ButtonStyle"     onClick="iImage()"          title="Image"           value="Image">
        <input type="button" class="ButtonStyle"     onClick="iUndo()"           title="Undo last change"value="Undo">
        <input type="button" class="ButtonStyle"     onClick="iRedo()"           title="Redo last change"value="Redo">
        <!-- Hide(but keep)your normal textarea and place in the iFrame replacement for it -->
        <textarea style="display:none;" name="myTextArea" id="myTextArea" cols="100" rows="14"></textarea>

            <iframe name="richTextField" id="richTextField" style="border:#000000 1px solid; width:700px; height:300px;"contenteditable="true";>{{printf "%s" .Content}}</iframe>
        <!-- End replacing your normal textarea --> 
        <br /><br /><input  type="submit" name="myBtn" type="button" value="Submit" onclick="iFrame2Input()"/>

The Go Code:
Not quite sure what's the best way to deal with the different post method.
Would it be easier to put all the different inputs together and put them apart serverside? Or should I do for every post a different Handler Methode?

type Page struct {
Title string
Body []byte
iContent string
iContentArray []byte

func saveHandler(w http.ResponseWriter, r *http.Request, title string) {
body := r.FormValue(“title”)
p := &Page{Title: title, Body: []byte(body)}
err :=
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
http.Redirect(w, r, “/view/”+title, http.StatusFound)


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.