Detailed Description
Reference will now be made in detail to the embodiments of the present disclosure, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the drawings are exemplary and intended to be illustrative of the present disclosure, and should not be construed as limiting the present disclosure.
The following describes a method and an apparatus for embedding a web page in a document according to an embodiment of the present disclosure with reference to the drawings.
FIG. 1 is a flowchart illustrating a method for embedding a web page in a document according to an embodiment of the disclosure.
As shown in fig. 1, the method for embedding a web page in a document includes the following steps:
step 101, receiving an input preset instruction in a current document, and generating an input interface.
In practical application, when a user needs to embed webpage content into a current document, a specific website identifier is usually called up through a toolbar menu or a "/" mode, and then a webpage link is converted into a webpage through the website identifier, so that the webpage content is embedded into the current document. In order to solve the problems of complex embedded operation and poor user experience in the related technology, the preset instruction is input at the position where the current document needs to be embedded into the webpage content, so that the webpage embedded operation can be directly triggered by the input instruction, a specific website identifier does not need to be called through a toolbar to perform webpage embedded operation, the toolbar form in the document is effectively reduced, simplicity and convenience are realized, and the user experience is improved.
The preset instruction may be a character used for evoking an embedded button of a web page, for example, an "@" character, and of course, the user may also set the character used for evoking the embedded button of the web page according to a use habit, which is not specifically limited herein.
Use the '@' character as an example, when the user need imbed webpage content in current document, can directly input the '@' character in the position department that current document needs to imbed webpage content, and then when discernment input character is the '@' character, can judge that user operation is the embedded operation of webpage, then trigger embedded operation, and generate the input interface who is used for the input website, and need not to arouse specific website recognizer through the toolbar and carry out the embedded operation of webpage, effectively alleviate the toolbar form in the document, and is simple and convenient, promote user experience.
In the embodiment of the present disclosure, after receiving the input first instruction in the current document, the method further includes: judging whether a user triggers a webpage embedded button or not; and if the webpage embedded button is triggered, generating an input interface, otherwise, not responding to the webpage embedded operation.
In practical application, when a user needs to embed webpage content in a current document, firstly, the user can directly call a function panel after inputting a '@' character so as to further determine whether the user needs to embed a webpage, if the user selects a webpage embedded button, an input interface for inputting a website is generated, if the user does not select the webpage embedded button, no webpage embedded operation is responded, and if the input information of the user is '@ + website', the user can input the website.
It should be noted that, when the user needs to embed other content in the current document, the user can also directly call the function panel by inputting a preset instruction, that is, the function panel may include other buttons, such as a picture embedded button, a form embedded button, and the like, in addition to the webpage embedded button, so that the user can select a specific operation according to the actual use requirement. For example, the user needs to embed a form in the current document, and selects a form embedding button after calling up the function panel, thereby performing a form embedding operation. In addition, if the user needs to input the character itself, no operation may be selected.
For example, the function panel is invoked after the user inputs the "@" character, wherein the function panel may include various embedded buttons, and when the user needs to embed a web page in the current document, the user clicks the embedded button of the web page to generate an input interface for inputting a web address. Of course, the user can select other operation buttons on the panel according to actual operation requirements. In addition, if the user needs to enter the "@" character itself, the panel may be closed directly.
Step 102, receiving input first content in an input interface, and analyzing a link character after the first content is the link character, wherein the first content has a first format attribute.
Wherein, the link character is a character forming a website to link a webpage according to the link character; the first format attribute may be a web address attribute.
Specifically, after the first content is identified, it is necessary to further determine a format attribute that the first content has, and if the format attribute is not the first format attribute, no operation is responded; if the first format attribute is the first format attribute, for example, the first content has the attribute of being a web address, the first content may be determined as a link character, and the link character may be further parsed to link the web page through the link character.
Further, before parsing the link character, the method further includes: judging whether the URL type of the link character meets a preset condition or not; if the preset condition is met, analyzing the link character; and if the preset condition is not met, prompting a danger warning.
The technical personnel in the art can set the preset conditions according to the actual situation, which is not specifically limited herein, for example, regular expression technology can be adopted to judge whether the URL type is a safe URL type.
That is to say, the present disclosure can identify all safe web page links, and effectively solve the problem that a "/" mode in the related art invokes a specific web site identifier to perform web page embedding operation and can only identify a specific web site, after the present disclosure directly triggers web page embedding operation through link characters, if the link characters are unsafe links, the present disclosure directly reminds a user that the links are dangerous, and can warn the user that the links are dangerous through various modes, for example, the present disclosure can prompt the user that the links are unsafe through a pop-up window mode, and certainly, can prompt the user through other modes, and is not specifically limited herein.
For example, when the link character is judged to be an unsafe link, the user is prompted directly in a popup mode. The link is noticed to have danger, and the user selects whether to continue to operate according to the danger warning, so that when the link is judged to be unsafe, the user is reminded of unsafe connection, and the use experience of the user is improved.
Of course, if the link character is safe, the link character is analyzed, for example, the link character is converted into a corresponding Iframe HTML code, so that the applicability of link character recognition is effectively improved, and the user is promoted.
And 103, extracting webpage information of the target webpage pointed by the link character.
Specifically, after the link character is parsed and linked to the target webpage through the link character, webpage information of the target webpage, such as video, data table, map orientation, and the like, is extracted.
And 104, generating second content according to the webpage information, and loading the second content to the specified position of the current document, wherein the second content has a second format attribute.
The second format attribute may be a web page attribute.
Specifically, after the webpage information is extracted, second content is generated according to the webpage attribute, and the format attribute of the second content is further judged, if the format attribute is not the second format attribute, the second content is not loaded, and the user can regenerate according to the webpage information or regenerate after regenerating the webpage information; if the second format attribute is the second format attribute, for example, the second content has a web page attribute, that is, the second content is an embedded web page, the embedded web page is directly loaded into the current document, so that the content of the web page link in the document can be directly viewed without secondary skip, for example, the web page is viewed, the video is played, and the like, and further, the content form of the document can be enriched, and the user experience is improved.
The method for embedding the web page in the document is further described by a specific example.
In a first example of the present disclosure, the preset instruction takes an "@" character as an example, and specifically includes:
when the user need imbed webpage content in current document, at first, directly need imbed webpage content's position department input "@" character at current document, and then arouse the function panel through "@" to the user can directly trigger the embedded operation of webpage through "@" character, need not to arouse specific website recognizer through the toolbar and carry out the embedded operation of webpage, effectively alleviates the toolbar form in the document, and is simple convenient, promotes user's use and experiences. Then, the user clicks a webpage embedded button, then pastes the copied webpage link in a dialog box of the input interface, and clicks a "conform" button. Finally, the embedded webpage is generated, so that a user can directly view the webpage, play videos and the like in the document, then the user can directly load the embedded webpage into the current document, the content of the webpage link in the document can be directly viewed without secondary skip, the content form of the document is enriched, and the use experience of the user is improved.
In a second example of the present disclosure, the preset instruction takes an "@" character as an example, and specifically includes:
step a, monitoring a keyboard keydown event of an editor, and calling a response function when the input character is judged to be '@'.
And b, calculating the current cursor position, and displaying the URL input floating frame at the position.
Step c, after a user inputs a URL and clicks a confirmation button, judging whether the URL is a safe URL type by adopting a regular expression technology, and if so, executing an Iframe insertion program; if not, the danger warning is prompted.
And d, converting the URL character string into a corresponding Iframe HTML code.
Step e, calling a browser API execCommand ('InsertHTML'), and inserting the generated HTML code into the editor.
And f, rendering the browser to display the embedded webpage content.
According to the method for embedding the webpage in the document, which is provided by the embodiment of the disclosure, the webpage embedding operation can be directly triggered by an input instruction, so that the embedded webpage can be directly generated in the current document according to the webpage link, a specific website identifier does not need to be called through a toolbar to perform the webpage embedding operation, the toolbar form in the document is effectively reduced, the method is convenient and fast, all safe webpage links can be identified, the problem that the specific website can only be identified by a '/' mode in the related technology is effectively solved, the embedded webpage can be directly loaded into the current document, the content of the webpage link in the document can be directly checked without secondary skip, the content form of the document can be enriched, the user experience can be improved, and the method is simple and easy to implement.
Based on the previous embodiment, the embodiment of the present disclosure further provides another method for embedding a web page in a document, so as to explain how to update the embedded web page in real time.
As shown in fig. 2, an embodiment of the present disclosure further provides a method for embedding a web page in a document, including the following steps:
step 201, receiving an input preset instruction in a current document, and generating an input interface.
Step 202, receiving input first content in the input interface, and after the first content is a link character, analyzing the link character, wherein the first content has a first format attribute.
Step 203, extracting the webpage information of the target webpage pointed by the link character.
And 204, generating second content according to the webpage information, and loading the second content to the specified position of the current document, wherein the second content has a second format attribute.
The description of steps 201-204 can refer to the description of steps 101-104.
In practical applications, since the web page information is updated in real time, in order to ensure that the second content of the current document is not distorted, the second content may be updated in real time after the second content is loaded into the current document. And step 205 is performed before updating the second content.
Step 205, judging whether the target webpage pointed by the link character is invalid, if so, executing step 206; if so, step 207 is performed.
If the document is invalid, the second content at the specified position of the current document is not updated, step 206.
That is, if the target web page pointed to by the link character is invalid, for example, the target web page does not exist, the second content is not updated.
Step 207, if the current webpage information of the target webpage is valid, the current webpage information of the target webpage is collected.
That is, the second content may be updated while the target web page pointed to by the link character is valid. When the second content is updated, first, the current webpage information of the target webpage can be obtained according to the link character, and then the current webpage information of the target webpage is collected.
In the embodiment of the disclosure, an updating instruction of a user is received, and current webpage information is collected according to the updating instruction; and/or acquiring current webpage information after a preset time length; and/or, collecting current web page information when a user opens a document.
That is to say, when the second content is updated, there are many ways to trigger the current webpage information collection, and one or more ways described above may be adopted to collect the current webpage information, which is not limited herein.
The (1) user may send the update instruction by clicking an update button, or may send the update instruction by another method, which is not limited specifically herein. For example, the user needs to update the second content, and may directly click an update button on the second content, so that an update instruction may be sent to collect current web page information. (2) The preset time duration can be set to be half an hour, one hour and the like, and a person skilled in the art can specifically set the preset time duration according to the webpage updating rule, and the preset time duration is not specifically limited, so that the current webpage information is automatically acquired after the preset time is reached. It should be noted that, acquiring the current webpage information after the preset time duration means acquiring after the preset time duration after the second content is updated last time.
And step 208, updating the second content of the specified position of the current document according to the current webpage information.
Specifically, after the current webpage information is collected, the second content, namely the embedded webpage, is updated according to the current webpage information, so that real-time updating of the embedded webpage of the current document can be achieved, further, the embedded webpage content of the current document can be effectively guaranteed not to be distorted, and the use experience of a user is improved.
It should be noted that the updated second content may be automatically embedded into the current document, and the presentation form is automatically adjusted, so as to improve the user experience.
According to the method for embedding the webpage in the document provided by the embodiment of the disclosure, the webpage embedding operation can be directly triggered by the input instruction, so that the webpage can be directly generated in the current document according to the webpage link without calling a specific website identifier through a toolbar to perform the webpage embedding operation, the toolbar form in the document is effectively lightened, the method is convenient and quick, all safe webpage links can be identified, the problem that the specific website can only be identified by the '/' mode in the related technology is effectively solved, the embedded webpage can be directly loaded into the current document, the content of the webpage link in the document can be directly checked without secondary skip, the content form of the document is effectively enriched, the embedded webpage in the current document can be updated in real time, the embedded webpage content in the current document is effectively ensured not to be distorted, and the use experience of a user is effectively improved, the method is simple and easy to realize.
Next, an apparatus for embedding a web page in a document according to an embodiment of the present disclosure is described with reference to the drawings.
FIG. 3 is a block diagram of an apparatus for embedding a web page in a document according to an embodiment of the present disclosure.
As shown in fig. 3, the apparatus 300 for embedding a web page in a document includes: a first generation module 310, a parsing module 320, an extraction module 330, and a second generation module 340.
The first generating module 310 is configured to receive an input preset instruction in a current document, and generate an input interface. The parsing module 320 is configured to receive an input first content in the input interface, and parse the link character after the first content is the link character, where the first content has a first format attribute. The extracting module 330 is configured to extract webpage information of a target webpage pointed by the link character. The second generating module 340 is configured to generate second content according to the web page information, and load the second content to a specified location of the current document, where the second content has a second format attribute.
In one embodiment of the present disclosure, receiving a web page inline request, the identifying module 310 includes: a judging unit and a receiving unit.
The judging unit is used for judging whether the input character is a preset link character or not when receiving the webpage embedded request. The receiving unit is used for detecting whether a webpage embedded button is triggered or not when the input character is a preset link character so as to receive a webpage embedded request after triggering.
In one embodiment of the present disclosure, as shown in fig. 4, the apparatus 300 of the embodiment of the present disclosure further includes: an acquisition module 350 and an update module 360.
The collecting module 350 is configured to collect current web page information of the target web page. The updating module 360 is configured to update the second content at the specified location of the current document according to the current webpage information.
In one embodiment of the present disclosure, the acquisition module 350 includes: the device comprises a first acquisition unit, a second acquisition unit and a third acquisition unit.
The first acquisition unit receives an update instruction of a user and acquires current webpage information according to the update instruction. And/or the second acquisition unit is used for acquiring the current webpage information after the preset time length. And/or the third acquisition unit acquires current webpage information when a user opens the document.
In one embodiment of the present disclosure, as shown in fig. 5, the apparatus 300 of the embodiment of the present disclosure further includes: a first decision block 370 and a no update block 380.
The first determining module 370 is configured to determine whether the target webpage pointed by the link character is invalid or not before collecting the current webpage information of the target webpage. The non-update module 380 is configured to not update the second content at the specified location of the current document when the target webpage pointed by the link character fails. The collecting module 350 is configured to collect current webpage information of the target webpage when the target webpage pointed by the link character is valid.
In one embodiment of the present disclosure, as shown in fig. 6, the apparatus 300 of the embodiment of the present disclosure further includes: a second decision module 390 and a prompt module 3100.
The second determining module 390 is configured to determine whether the URL type of the link character meets a preset condition before the link character is parsed. The prompting module 3100 is configured to prompt a hazard warning when a preset condition is not satisfied. The parsing module 320 is configured to parse the link character when a preset condition is met.
It should be noted that the explanation of the embodiment of the method for embedding a web page in a document is also applicable to the apparatus for embedding a web page in a document of the embodiment, and is not repeated here.
According to the device for embedding the webpage in the document, the webpage embedding operation can be directly triggered by the link characters, so that the embedded webpage is generated according to the webpage link, a specific website identifier does not need to be called through a toolbar to perform the webpage embedding operation, the shape of the toolbar in the document is effectively reduced, the device is convenient and quick, all safe webpage links can be identified, the problem that the '/' mode in the related technology can only identify a specific website is effectively solved, the embedded webpage can be directly loaded into the current document, the content of the webpage link in the document can be directly checked without secondary skip, the content shape of the document is effectively enriched, the embedded webpage in the current document can be updated in real time, the embedded webpage content is effectively guaranteed not to be distorted, the use experience of a user is effectively improved, and the device is simple and easy to implement.
In order to implement the foregoing embodiments, the present disclosure also provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the program to:
receiving an input preset instruction in a current document, and generating an input interface;
receiving input first content in an input interface, and analyzing a link character after the first content is the link character, wherein the first content has a first format attribute;
extracting webpage information of a target webpage pointed by the link characters; and
and generating second content according to the webpage information, and loading the second content to the specified position of the current document, wherein the second content has a second format attribute.
Referring now to fig. 7, a schematic diagram of an electronic device (e.g., a terminal device or server) 700 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 7, electronic device 700 may include a processing means (e.g., central processing unit, graphics processor, etc.) 701 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from storage 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the electronic apparatus 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Generally, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 708 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 illustrates an electronic device 700 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication means 709, or may be installed from the storage means 708, or may be installed from the ROM 702. The computer program, when executed by the processing device 701, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving an input preset instruction in a current document, and generating an input interface; receiving input first content in an input interface, and analyzing a link character after the first content is the link character, wherein the first content has a first format attribute; extracting webpage information of a target webpage pointed by the link characters; and generating second content according to the webpage information, and loading the second content to the specified position of the current document, wherein the second content has a second format attribute.
Alternatively, the computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving an input preset instruction in a current document, and generating an input interface; receiving input first content in an input interface, and analyzing a link character after the first content is the link character, wherein the first content has a first format attribute; extracting webpage information of a target webpage pointed by the link characters; and generating second content according to the webpage information, and loading the second content to the specified position of the current document, wherein the second content has a second format attribute.
Alternatively, the computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving an input preset instruction in a current document, and generating an input interface; receiving input first content in an input interface, and analyzing a link character after the first content is the link character, wherein the first content has a first format attribute; extracting webpage information of a target webpage pointed by the link characters; and generating second content according to the webpage information, and loading the second content to the specified position of the current document, wherein the second content has a second format attribute.
Alternatively, the computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving an input preset instruction in a current document, and generating an input interface; receiving input first content in an input interface, and analyzing a link character after the first content is the link character, wherein the first content has a first format attribute; extracting webpage information of a target webpage pointed by the link characters; and generating second content according to the webpage information, and loading the second content to the specified position of the current document, wherein the second content has a second format attribute.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation of the unit itself, for example, the first retrieving unit may also be described as a "unit for retrieving at least two internet protocol addresses".